зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1801716 - Handle missing hostname variables; r=nordzilla
The HOST_NAME could be undefined if the URL is not valid and throws. The broader functions that use it would still be defined due to hoisting. Differential Revision: https://phabricator.services.mozilla.com/D164462
This commit is contained in:
Родитель
4842dfc9f6
Коммит
0515d6a08f
|
@ -24,8 +24,16 @@ const { parse, pemToDER } = globalThis.certDecoderInitializer(
|
|||
|
||||
const formatter = new Intl.DateTimeFormat();
|
||||
|
||||
const HOST_NAME =
|
||||
new URL(RPMGetInnerMostURI(document.location.href)).hostname ?? "";
|
||||
const HOST_NAME = getHostName();
|
||||
|
||||
function getHostName() {
|
||||
try {
|
||||
return new URL(RPMGetInnerMostURI(document.location.href)).hostname;
|
||||
} catch (error) {
|
||||
console.error("Could not parse URL", error);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
// Used to check if we have a specific localized message for an error.
|
||||
const KNOWN_ERROR_TITLE_IDS = new Set([
|
||||
|
@ -300,7 +308,7 @@ function initPage() {
|
|||
document.getElementById("errorShortDesc").hidden = true;
|
||||
|
||||
document.l10n.setAttributes(longDesc, "csp-xfo-blocked-long-desc", {
|
||||
hostname: document.location.hostname, // FIXME - should this be HOST_NAME?
|
||||
hostname: document.location.hostname ?? "", // FIXME - should this be HOST_NAME?
|
||||
});
|
||||
longDesc = null;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче