From e1574aa50968cdaaf34abc9259af572a97700fbb Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Sat, 26 May 2012 12:49:16 -0700 Subject: Ignore any matches between the query and the target which are 2 characters are less. --- background_scripts/completion.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/completion.js b/background_scripts/completion.js index 8bdbc637..2e78ac9d 100644 --- a/background_scripts/completion.js +++ b/background_scripts/completion.js @@ -137,6 +137,7 @@ var completion = (function() { var displayUrl = this.stripTrailingSlash(url); function createLazyCompletion(query) { + // We want shorter URLs (i.e. top level domains) to rank more highly. var relevancy = url.length / fuzzyMatcher.calculateRelevancy(query, completionString); return new LazyCompletionResult(relevancy, function() { return { @@ -436,9 +437,11 @@ var completion = (function() { str = self.normalize(str); var sum = 0; - // only iterate over slices of the query starting at an offset up to 10 to save resources + // Ignore any matches between the query and the str which are 2 characters are less. + var minimumCharacterMatch = 3; + // only iterate over slices of the query starting at an offset up to 20 to save resources for (var start = 0; start < 20 && start < query.length; ++start) { - for (var i = query.length; i >= start; --i) { + for (var i = query.length; i >= start + (minimumCharacterMatch - 1); --i) { if (str.indexOf(query.slice(start, i)) >= 0) { var length = i - start; sum += length * length; -- cgit v1.2.3