Bug 461483 - Ignore 'www.' when searching in the the awesome bar [r=mak]

Strip out www. from found urls and the query after already stripping off http://, etc. Update tests now that www. can't be matched.

--HG--
extra : rebase_source : 352f2dfb302a56fc3e83dffcbb1bd2a53208510d
This commit is contained in:
Edward Lee 2009-07-24 17:57:26 -07:00
Родитель 1bfda1aef3
Коммит 3a851a4dc9
3 изменённых файлов: 31 добавлений и 15 удалений

Просмотреть файл

@ -94,6 +94,9 @@ namespace places {
_fixedSpec.Cut(0, 8);
else if (StringBeginsWith(_fixedSpec, NS_LITERAL_STRING("ftp://")))
_fixedSpec.Cut(0, 6);
if (StringBeginsWith(_fixedSpec, NS_LITERAL_STRING("www.")))
_fixedSpec.Cut(0, 4);
}
/* static */

Просмотреть файл

@ -581,6 +581,9 @@ nsPlacesAutoComplete.prototype = {
else if (uri.indexOf("ftp://") == 0)
uri = uri.slice(6);
if (uri.indexOf("www.") == 0)
uri = uri.slice(4);
return this._textURIService.unEscapeURIForUI("UTF-8", uri);
},

Просмотреть файл

@ -38,6 +38,9 @@
* Test bug 424717 to make sure searching with an existing location like
* http://site/ also matches https://site/ or ftp://site/. Same thing for
* ftp://site/ and https://site/.
*
* Test bug 461483 to make sure a search for "w" doesn't match the "www." from
* site subdomains.
*/
// Define some shared uris and titles (each page needs its own uri)
@ -48,6 +51,8 @@ let kURIs = [
"ftp://site/",
"https://www.site/",
"https://site/",
"http://woohoo/",
"http://wwwwwwacko/",
];
let kTitles = [
"title",
@ -60,26 +65,31 @@ addPageBook(2, 0);
addPageBook(3, 0);
addPageBook(4, 0);
addPageBook(5, 0);
addPageBook(6, 0);
addPageBook(7, 0);
let allSite = [0,1,2,3,4,5];
let allWWW = [0,4];
// Provide for each test: description; search terms; array of gPages indices of
// pages that should match; optional function to be run before the test
let gTests = [
["0: http://www. matches all www.site",
kURIs[0], allWWW],
["1: http:// matches all site",
kURIs[1], allSite],
["2: ftp://ftp. matches itself",
kURIs[2], [2]],
["3: ftp:// matches all site",
kURIs[3], allSite],
["4: https://www. matches all www.site",
kURIs[4], allWWW],
["5: https:// matches all site",
kURIs[5], allSite],
["0: http://www.site matches all site", "http://www.site", allSite],
["1: http://site matches all site", "http://site", allSite],
["2: ftp://ftp.site matches itself", "ftp://ftp.site", [2]],
["3: ftp://site matches all site", "ftp://site", allSite],
["4: https://www.site matches all site", "https://www.site", allSite],
["5: https://site matches all site", "https://site", allSite],
["6: www.site matches all site", "www.site", allSite],
["6: www.site matches all www.site",
"www.site", allWWW],
["7: w matches none of www.", "w", [6,7]],
["8: http://w matches none of www.", "w", [6,7]],
["9: http://www.w matches none of www.", "w", [6,7]],
["10: ww matches none of www.", "ww", [7]],
["11: http://ww matches none of www.", "http://ww", [7]],
["12: http://www.ww matches none of www.", "http://www.ww", [7]],
["13: www matches none of www.", "www", [7]],
["14: http://www matches none of www.", "http://www", [7]],
["15: http://www.www matches none of www.", "http://www.www", [7]],
];