From 679c05aa4f1a4585181f502ef57a05a931b6a94b Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Thu, 10 Aug 2017 16:07:56 -0400 Subject: [PATCH] Return about:[name] as origin for about: pages Fix #10410 Auditors: @diracdeltas Notes this is in the branch of code which requires muon only so it is already in unit tests but we test it with the wrong url parsing from node. --- js/lib/urlutil.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/js/lib/urlutil.js b/js/lib/urlutil.js index 2ab1c1338a5..0ad7379945d 100644 --- a/js/lib/urlutil.js +++ b/js/lib/urlutil.js @@ -413,8 +413,9 @@ const UrlUtil = { }, /** - * Gets a site origin (scheme + hostname + port) from a URL or null if not - * available. + * Gets a site origin (scheme + hostname + port) from a URL or null if not available. + * Warning: For unit tests, this currently runs as node without the parsed.origin + * branch of code, but in muon this runs through the parsed.origin branch of code. * @param {string} location * @return {string|null} */ @@ -429,8 +430,11 @@ const UrlUtil = { } let parsed = urlParse(location) - if (parsed.origin) { - // parsed.origin is specific to muon.url.parse + // parsed.origin is specific to muon.url.parse + if (parsed.origin !== undefined) { + if (parsed.protocol === 'about:') { + return [parsed.protocol, parsed.path].join('') + } return parsed.origin.replace(/\/+$/, '') } if (parsed.host && parsed.protocol) {