Commit 8af90b32 authored by Arthur Edelstein's avatar Arthur Edelstein
Browse files

Bug 21999: Detect homepage URLs more effectively

parent 90c35ef9
...@@ -2275,6 +2275,25 @@ function torbutton_get_current_accept_language_value(aURI) ...@@ -2275,6 +2275,25 @@ function torbutton_get_current_accept_language_value(aURI)
return null; return null;
} }
// Take URL strings the user has specified for a homepage
// and normalize it so it looks like a real URL.
function torbutton_normalize_homepage_url_string(aURLString)
{
if (!aURLString) return null;
if (typeof aURLString !== "string") return null;
let url;
try {
url = new URL(aURLString);
} catch (e) {
try {
url = new URL("http://" + aURLString);
} catch (e) {
return null;
}
}
return url.href;
}
function torbutton_is_homepage_url(aURI) function torbutton_is_homepage_url(aURI)
{ {
if (!aURI) if (!aURI)
...@@ -2292,7 +2311,8 @@ function torbutton_is_homepage_url(aURI) ...@@ -2292,7 +2311,8 @@ function torbutton_is_homepage_url(aURI)
if (!homePageURLs) if (!homePageURLs)
return false; return false;
let urls = homePageURLs.split('|'); let urls = homePageURLs.split('|')
.map(torbutton_normalize_homepage_url_string);
return (urls.indexOf(aURI.spec) >= 0); return (urls.indexOf(aURI.spec) >= 0);
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment