зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1598345 - [urlbar.view.stripHttps] Strip single trailing slash from URLs. r=mak
Differential Revision: https://phabricator.services.mozilla.com/D54163 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
940d17feab
Коммит
4b03dfa26b
|
@ -202,6 +202,7 @@ class UrlbarResult {
|
|||
let url = payloadInfo.displayUrl[0];
|
||||
if (url && UrlbarPrefs.get("trimURLs")) {
|
||||
if (UrlbarPrefs.get("view.stripHttps")) {
|
||||
url = BrowserUtils.removeSingleTrailingSlashFromURL(url);
|
||||
if (url.startsWith("https://")) {
|
||||
url = url.substring(8);
|
||||
}
|
||||
|
|
|
@ -111,6 +111,26 @@ add_task(async function test_url_result() {
|
|||
);
|
||||
});
|
||||
|
||||
add_task(async function test_url_result_no_path() {
|
||||
await testResult(
|
||||
{
|
||||
query: "ample",
|
||||
title: "The Title",
|
||||
url: "https://example.com/",
|
||||
},
|
||||
{
|
||||
displayedUrl:
|
||||
(UrlbarPrefs.get("view.stripHttps") ? "" : "https://") + "example.com",
|
||||
highlightedTitle: [["The Title", false]],
|
||||
highlightedUrl: [
|
||||
[(UrlbarPrefs.get("view.stripHttps") ? "" : "https://") + "ex", false],
|
||||
["ample", true],
|
||||
[".com", false],
|
||||
],
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function test_url_result_no_trimming() {
|
||||
Services.prefs.setBoolPref("browser.urlbar.trimURLs", false);
|
||||
|
||||
|
|
|
@ -781,6 +781,11 @@ var BrowserUtils = {
|
|||
});
|
||||
},
|
||||
|
||||
removeSingleTrailingSlashFromURL(aURL) {
|
||||
// remove single trailing slash for http/https/ftp URLs
|
||||
return aURL.replace(/^((?:http|https|ftp):\/\/[^/]+)\/$/, "$1");
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a URL which has been trimmed by removing 'http://' and any
|
||||
* trailing slash (in http/https/ftp urls).
|
||||
|
@ -792,8 +797,7 @@ var BrowserUtils = {
|
|||
// This function must not modify the given URL such that calling
|
||||
// nsIURIFixup::createFixupURI with the result will produce a different URI.
|
||||
|
||||
// remove single trailing slash for http/https/ftp URLs
|
||||
let url = aURL.replace(/^((?:http|https|ftp):\/\/[^/]+)\/$/, "$1");
|
||||
let url = this.removeSingleTrailingSlashFromURL(aURL);
|
||||
|
||||
// remove http://
|
||||
if (!url.startsWith("http://")) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче