From 081ffddda6ee3419dc6c706458ad3f006f4f1a97 Mon Sep 17 00:00:00 2001 From: hackademix Date: Sun, 21 Jul 2019 02:21:49 +0200 Subject: More graceful handling of chrome: origins. --- src/common/Policy.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/common/Policy.js b/src/common/Policy.js index c61596d..3f7e0c7 100644 --- a/src/common/Policy.js +++ b/src/common/Policy.js @@ -84,11 +84,11 @@ var {Permissions, Policy, Sites} = (() => { static origin(site) { if (!site) return ""; try { - let objUrl = site.href ? site : new URL(site); - let origin = objUrl.origin; + let objUrl = (typeof site === "object" && "origin" in site) ? site : site.startsWith("chrome:") ? {origin: "chrome:" } : new URL(site); + let {origin} = objUrl; return origin === "null" ? Sites.cleanUrl(objUrl) || site : origin; } catch (e) { - console.error(e); + error(e); }; return site.origin || site; } -- cgit v1.2.3