diff --git a/apply-css/background.js b/apply-css/background.js index 3c0b1aad..8846b0b1 100644 --- a/apply-css/background.js +++ b/apply-css/background.js @@ -27,11 +27,11 @@ function toggleCSS(tab) { /* Returns true only if the URL's protocol is in APPLICABLE_PROTOCOLS. +Argument url must be a valid URL string. */ function protocolIsApplicable(url) { - var anchor = document.createElement('a'); - anchor.href = url; - return APPLICABLE_PROTOCOLS.includes(anchor.protocol); + const protocol = (new URL(url)).protocol; + return APPLICABLE_PROTOCOLS.includes(protocol); } /*