aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts
diff options
context:
space:
mode:
Diffstat (limited to 'background_scripts')
-rw-r--r--background_scripts/completion_engines.coffee10
-rw-r--r--background_scripts/completion_search.coffee6
2 files changed, 8 insertions, 8 deletions
diff --git a/background_scripts/completion_engines.coffee b/background_scripts/completion_engines.coffee
index 9a88d491..dcbf99c6 100644
--- a/background_scripts/completion_engines.coffee
+++ b/background_scripts/completion_engines.coffee
@@ -46,14 +46,14 @@ class Google extends GoogleXMLRegexpEngine
class GoogleWithPrefix
constructor: (prefix, args...) ->
@engine = new Google args...
- @prefix = "#{prefix.trim()} "
- @queryTerms = @prefix.split /\s+/
+ @prefix = "#{prefix} "
+ @queryTerms = prefix.split /\s+/
match: (args...) -> @engine.match args...
getUrl: (queryTerms) -> @engine.getUrl [ @queryTerms..., queryTerms... ]
parse: (xhr) ->
- @engine.parse(xhr)
- .filter (suggestion) => suggestion.startsWith @prefix
- .map (suggestion) => suggestion[@prefix.length..].ltrim()
+ for suggestion in @engine.parse xhr
+ continue unless suggestion.startsWith @prefix
+ suggestion[@prefix.length..].ltrim()
# For Google Maps, we add the prefix "map of" to the query, and send it to Google's general search engine,
# then strip "map of" from the resulting suggestions.
diff --git a/background_scripts/completion_search.coffee b/background_scripts/completion_search.coffee
index d89eb278..b26194e6 100644
--- a/background_scripts/completion_search.coffee
+++ b/background_scripts/completion_search.coffee
@@ -12,7 +12,7 @@ CompletionSearch =
get: (searchUrl, url, callback) ->
xhr = new XMLHttpRequest()
xhr.open "GET", url, true
- xhr.timeout = 1000
+ xhr.timeout = 2500
xhr.ontimeout = xhr.onerror = -> callback null
xhr.send()
@@ -115,8 +115,8 @@ CompletionSearch =
console.log "GET", url if @debug
catch
suggestions = []
- # We allow failures to be cached too, but remove them after just thirty minutes.
- Utils.setTimeout 30 * 60 * 1000, => @completionCache.set completionCacheKey, null
+ # We allow failures to be cached too, but remove them after just thirty seconds.
+ Utils.setTimeout 30 * 1000, => @completionCache.set completionCacheKey, null
console.log "fail", url if @debug
callback suggestions