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}`; }