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
This commit is contained in:
mzivil 2024-02-02 15:46:30 -05:00
parent 068f1e9eba
commit 99e547e6ae
1 changed files with 3 additions and 1 deletions

View File

@ -561,7 +561,9 @@ export default {
let similar = `(http(s)?://)?${uri}/?` let similar = `(http(s)?://)?${uri}/?`
const whitelist = ['news.ycombinator.com/item', 'bitcointalk.org/index.php'] const whitelist = ['news.ycombinator.com/item', 'bitcointalk.org/index.php']
const youtube = ['www.youtube.com', 'youtube.com', 'm.youtube.com', 'youtu.be'] 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}` similar += `\\${urlObj.search}`
} else if (youtube.includes(urlObj.hostname)) { } else if (youtube.includes(urlObj.hostname)) {
// extract id and create both links // extract id and create both links