Refactor URL parsing, fix equalities
This commit is contained in:
parent
629926126e
commit
f481bcdbfb
|
@ -8,16 +8,15 @@ const excludedPaths = [
|
||||||
|
|
||||||
chrome.webRequest.onBeforeRequest.addListener(
|
chrome.webRequest.onBeforeRequest.addListener(
|
||||||
function(details) {
|
function(details) {
|
||||||
const urlParser = document.createElement("a");
|
const url = new URL(details.url);
|
||||||
urlParser.href = details.url;
|
|
||||||
|
|
||||||
if (urlParser.hostname == "old.reddit.com") return;
|
if (url.hostname === "old.reddit.com") return;
|
||||||
|
|
||||||
for (const path of excludedPaths) {
|
for (const path of excludedPaths) {
|
||||||
if (urlParser.pathname.indexOf(path) == 0) return;
|
if (url.pathname.indexOf(path) === 0) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {redirectUrl: oldReddit + urlParser.pathname + urlParser.search + urlParser.hash};
|
return {redirectUrl: oldReddit + url.pathname + url.search + url.hash};
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
urls: [
|
urls: [
|
||||||
|
|
Loading…
Reference in New Issue