зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1157503 - NewTabUtils.extractSite should try-catch nsIURI.asciiHost. r=ttaubert,Mardak
This commit is contained in:
Родитель
1028ac00f3
Коммит
aefa8b95be
|
@ -1311,15 +1311,17 @@ this.NewTabUtils = {
|
|||
* @return The "site" string or null
|
||||
*/
|
||||
extractSite: function Links_extractSite(url) {
|
||||
let uri;
|
||||
let host;
|
||||
try {
|
||||
uri = Services.io.newURI(url, null, null);
|
||||
// Note that nsIURI.asciiHost throws NS_ERROR_FAILURE for some types of
|
||||
// URIs, including jar and moz-icon URIs.
|
||||
host = Services.io.newURI(url, null, null).asciiHost;
|
||||
} catch (ex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Strip off common subdomains of the same site (e.g., www, load balancer)
|
||||
return uri.asciiHost.replace(/^(m|mobile|www\d*)\./, "");
|
||||
return host.replace(/^(m|mobile|www\d*)\./, "");
|
||||
},
|
||||
|
||||
init: function NewTabUtils_init() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче