From c380cb5c9c8dd786b8203d2ed10d451da2ece2b7 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Tue, 23 Oct 2012 10:27:57 +0100 Subject: Code cleanup, as requested by in3/Jez Ng here: - https://github.com/philc/vimium/pull/682. --- lib/utils.coffee | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/utils.coffee b/lib/utils.coffee index e4debe71..778d338f 100644 --- a/lib/utils.coffee +++ b/lib/utils.coffee @@ -91,19 +91,15 @@ Utils = # Creates a search URL from the given :query. createSearchUrl: (query) -> - # Escape explicitly to encode characters like "+" correctly - # "http://www.google.com/search?q=" + encodeURIComponent(query) - # - # 1. pull default search engine from settungs - # 2. don't URLencode the "+", Google (and other search engines) doesn't - # require it, so it's probably ok - # - # note: query is already trimmed in convertToUrl + # 1. pull default search engine from settings + # 2. don't URLencode the "+", + # - chrome does not URLencode the "+" sign when sending requests to its + # default search engine, so we should do the same here # # note: it would be better to pull the default search engine from chrome # itself, but I'm not sure if/how that's possible # - Settings.get("defaultSearchUrl") + query.split(/\s+/).map(encodeURIComponent).join("+") + Settings.get("searchUrl") + query.split(/\s+/).map(encodeURIComponent).join("+") # 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. @@ -137,5 +133,3 @@ globalRoot.extend = (hash1, hash2) -> root = exports ? window root.Utils = Utils - -# vim: softtabstop=2 -- cgit v1.2.3