Bug 742776 - Use a case sensitive match for the URI path in inline autocomplete query.
authorMarco Bonardo <mbonardo@mozilla.com>
Thu, 19 Apr 2012 22:17:04 +0200
changeset 26420 fc9979908a292444c555157e4e32cfbdae96da9b
parent 26419 372cd2338fd1486d00dbaac072d202ac662fc73e
child 26421 42a38643a3b6d9182b0526e43c2f8567eb0bf578
push id1834
push userclokep@gmail.com
push dateMon, 23 Jan 2017 21:48:40 +0000
treeherdercomm-beta@293cffe83e59 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs742776
Bug 742776 - Use a case sensitive match for the URI path in inline autocomplete query. r=gavin a=desktop-only
suite/common/places/nsPlacesAutoComplete.js
--- a/suite/common/places/nsPlacesAutoComplete.js
+++ b/suite/common/places/nsPlacesAutoComplete.js
@@ -71,16 +71,17 @@ const kTopicShutdown = "places-shutdown"
 const kPrefChanged = "nsPref:changed";
 
 // Match type constants.  These indicate what type of search function we should
 // be using.
 const MATCH_ANYWHERE = Ci.mozIPlacesAutoComplete.MATCH_ANYWHERE;
 const MATCH_BOUNDARY_ANYWHERE = Ci.mozIPlacesAutoComplete.MATCH_BOUNDARY_ANYWHERE;
 const MATCH_BOUNDARY = Ci.mozIPlacesAutoComplete.MATCH_BOUNDARY;
 const MATCH_BEGINNING = Ci.mozIPlacesAutoComplete.MATCH_BEGINNING;
+const MATCH_BEGINNING_CASE_SENSITIVE = Ci.mozIPlacesAutoComplete.MATCH_BEGINNING_CASE_SENSITIVE;
 
 // AutoComplete index constants.  All AutoComplete queries will provide these
 // columns in this order.
 const kQueryIndexURL = 0;
 const kQueryIndexTitle = 1;
 const kQueryIndexFaviconURL = 2;
 const kQueryIndexBookmarked = 3;
 const kQueryIndexBookmarkTitle = 4;
@@ -1434,21 +1435,30 @@ urlInlineComplete.prototype = {
     // We don't need to search if we have no "/" separator, or if it's at
     // the end of the search text.
     if (lastSlashIndex == -1 ||
         lastSlashIndex == this._currentSearchString.length - 1) {
       this._finishSearch();
       return;
     }
 
+    // The URIs in the database are fixed up, so we can match on a lowercased
+    // host, but the path must be matched in a case sensitive way.
+    let pathIndex =
+      this._originalSearchString.indexOf("/", this._strippedPrefix.length);
+    this._currentSearchString = fixupSearchText(
+      this._originalSearchString.slice(0, pathIndex).toLowerCase() +
+      this._originalSearchString.slice(pathIndex)
+    );
+
     // Within the standard autocomplete query, we only search the beginning
     // of URLs for 1 result.
     let query = this._asyncQuery;
     let (params = query.params) {
-      params.matchBehavior = MATCH_BEGINNING;
+      params.matchBehavior = MATCH_BEGINNING_CASE_SENSITIVE;
       params.searchBehavior = Ci.mozIPlacesAutoComplete["BEHAVIOR_URL"];
       params.searchString = this._currentSearchString;
     }
 
     // Execute the async query
     let wrapper = new AutoCompleteStatementCallbackWrapper(this, this._db);
     this._pendingQuery = wrapper.executeAsync([query]);
   },