Bug 1724473 - Added an if statement at the bailout, enabling it to only work when the url starts with an alphanumeric. r=mak Bonardo <mbonardo@mozilla.com>

ran eslint to correct an error

compressed the if statements into 1 if using &&

wrote a test in the test_URIFixup_info.js file

fixed the test

Differential Revision: https://phabricator.services.mozilla.com/D129634
This commit is contained in:
tanju brunostar 2021-11-01 13:15:15 +00:00
parent 09b489fe8a
commit 3eaed4ffa9
2 changed files with 14 additions and 5 deletions

View File

@ -663,11 +663,12 @@ function checkAndFixPublicSuffix(info) {
// Quick bailouts for most common cases, according to Alexa Top 1 million.
if (
asciiHost.endsWith(".com") ||
asciiHost.endsWith(".net") ||
asciiHost.endsWith(".org") ||
asciiHost.endsWith(".ru") ||
asciiHost.endsWith(".de")
/^\w/.test(asciiHost) &&
(asciiHost.endsWith(".com") ||
asciiHost.endsWith(".net") ||
asciiHost.endsWith(".org") ||
asciiHost.endsWith(".ru") ||
asciiHost.endsWith(".de"))
) {
return {
suffix: asciiHost.substring(asciiHost.lastIndexOf(".") + 1),

View File

@ -508,6 +508,14 @@ var testcases = [
input: "?'.com",
keywordLookup: true,
},
{
input: ".com",
keywordLookup: true,
affectedByDNSForSingleWordHosts: true,
fixedURI: "http://.com/",
alternateURI: "https://www.com/",
protocolChange: true,
},
{
input: "' ?.com",
keywordLookup: true,