aboutsummaryrefslogtreecommitdiffstats
path: root/lib/utils.coffee
diff options
context:
space:
mode:
authorStephen Blott2015-05-06 07:40:46 +0100
committerStephen Blott2015-05-06 09:29:15 +0100
commit5752c0ead0a65fc2329515509f66e00bd6ee2f60 (patch)
tree0cc13d0e924c0daf69312036f2dc1fe28aa84494 /lib/utils.coffee
parent372e65d7b44c3f0ad3f522bd6b8c9cfacd693186 (diff)
downloadvimium-5752c0ead0a65fc2329515509f66e00bd6ee2f60.tar.bz2
Search completion; more tweaks.
Diffstat (limited to 'lib/utils.coffee')
-rw-r--r--lib/utils.coffee11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/utils.coffee b/lib/utils.coffee
index e97872f0..354d82f6 100644
--- a/lib/utils.coffee
+++ b/lib/utils.coffee
@@ -96,11 +96,12 @@ Utils =
query = query.split(/\s+/) if typeof(query) == "string"
query.map(encodeURIComponent).join "+"
- # Creates a search URL from the given :query.
- createSearchUrl: (query) ->
- # It would be better to pull the default search engine from chrome itself. However, unfortunately chrome
- # does not provide an API for doing so.
- Settings.get("searchUrl") + @createSearchQuery query
+ # Create a search URL from the given :query (using either the provided search URL, or the default one).
+ # It would be better to pull the default search engine from chrome itself. However, chrome does not provide
+ # an API for doing so.
+ createSearchUrl: (query, searchUrl = Settings.get("searchUrl")) ->
+ searchUrl += "%s" unless 0 <= searchUrl.indexOf "%s"
+ searchUrl.replace /%s/g, @createSearchQuery query
# Converts :string into a Google search if it's not already a URL. We don't bother with escaping characters
# as Chrome will do that for us.