Skip to content

Commit

Permalink
Merge pull request mdn#463 from madnificent/feature/use-url-interface…
Browse files Browse the repository at this point in the history
…-in-apply-css-example

Use URL interface in apply-css example
  • Loading branch information
Rob--W authored Feb 6, 2021
2 parents 2184fee + b1b8966 commit 1e984e6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions apply-css/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/*
Expand Down

0 comments on commit 1e984e6

Please sign in to comment.