From 99ac57090a1b8820f428b541c21f2cecae60fb96 Mon Sep 17 00:00:00 2001 From: yan Date: Thu, 10 Aug 2017 17:41:08 +0000 Subject: [PATCH] Fix getOrigin to work with muon.url.parse Fix https://github.com/brave/browser-laptop/issues/10391 Test Plan: 1. go to google.com 2. click 'remember this decision' and 'deny' when it asks for your location 3. close tab, open google.com again. it should not ask to see your location. --- js/lib/urlutil.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/lib/urlutil.js b/js/lib/urlutil.js index 7643eb15408..2ab1c1338a5 100644 --- a/js/lib/urlutil.js +++ b/js/lib/urlutil.js @@ -429,11 +429,14 @@ const UrlUtil = { } let parsed = urlParse(location) + if (parsed.origin) { + // parsed.origin is specific to muon.url.parse + return parsed.origin.replace(/\/+$/, '') + } if (parsed.host && parsed.protocol) { return parsed.slashes ? [parsed.protocol, parsed.host].join('//') : [parsed.protocol, parsed.host].join('') - } else { - return null } + return null } }