From 99e547e6ae5809dd29b00a768de8213d5decf09a Mon Sep 17 00:00:00 2001 From: mzivil <158518982+mzivil@users.noreply.github.com> Date: Fri, 2 Feb 2024 15:46:30 -0500 Subject: [PATCH] fix all hacker news and bitcoin talk links showing up as dupes It looks like a regression was introduced at some point, because the `uri` that's compared against the `whitelist` is a regular expression and not the url hostname + pathname as it was originally written. This brings back the original behavior of comparing the whitelist against the hostname + pathname --- api/resolvers/item.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/resolvers/item.js b/api/resolvers/item.js index 3addff9a..3b492725 100644 --- a/api/resolvers/item.js +++ b/api/resolvers/item.js @@ -561,7 +561,9 @@ export default { let similar = `(http(s)?://)?${uri}/?` const whitelist = ['news.ycombinator.com/item', 'bitcointalk.org/index.php'] const youtube = ['www.youtube.com', 'youtube.com', 'm.youtube.com', 'youtu.be'] - if (whitelist.includes(uri)) { + + const hostAndPath = stripTrailingSlash(urlObj.hostname + urlObj.pathname) + if (whitelist.includes(hostAndPath)) { similar += `\\${urlObj.search}` } else if (youtube.includes(urlObj.hostname)) { // extract id and create both links