From ae9df32adfe817afc87a2e5890008700e43a727f Mon Sep 17 00:00:00 2001 From: AmeliMeow <69979190+AmeliMeow@users.noreply.github.com> Date: Tue, 11 Oct 2022 14:13:10 +0300 Subject: [PATCH] Fixes SimonBrazell#9 - extension breaks for usernames starts with "tweets" --- background.js | 4 ++-- content-script.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/background.js b/background.js index 35831e5..6495a90 100644 --- a/background.js +++ b/background.js @@ -29,8 +29,8 @@ function redirectTwitter(url) { return `${instance}/pic/${encodeURIComponent(url.href)}`; } else if (url.host.split(".")[0] === "video") { return `${instance}/gif/${encodeURIComponent(url.href)}`; - } else if (url.pathname.includes("tweets")) { - return `${instance}${url.pathname.replace("/tweets", "")}${url.search}`; + } else if (url.pathname.endsWith("/tweets")) { + return `${instance}${url.pathname.replace(/\/tweets$/s, "")}${url.search}`; } else { return `${instance}${url.pathname}${url.search}`; } diff --git a/content-script.js b/content-script.js index 0c7afd9..56734cc 100644 --- a/content-script.js +++ b/content-script.js @@ -12,8 +12,8 @@ function redirectTwitter(url) { return `${instance}/pic/${encodeURIComponent(url.href)}`; } else if (url.host.split(".")[0] === "video") { return `${instance}/gif/${encodeURIComponent(url.href)}`; - } else if (url.pathname.includes("tweets")) { - return `${instance}${url.pathname.replace("/tweets", "")}${url.search}`; + } else if (url.pathname.endsWith("/tweets")) { + return `${instance}${url.pathname.replace(/\/tweets$/s, "")}${url.search}`; } else { return `${instance}${url.pathname}${url.search}`; }