more youtube dupe detection

This commit is contained in:
keyan 2023-01-11 16:04:50 -06:00
parent b7830261d8
commit 2b878e1a19
1 changed files with 2 additions and 2 deletions

View File

@ -472,13 +472,13 @@ export default {
let similar = `(http(s)?://)?${uri}/?`
const whitelist = ['news.ycombinator.com/item', 'bitcointalk.org/index.php']
const youtube = ['www.youtube.com', 'youtube.com', 'youtu.be']
const youtube = ['www.youtube.com', 'youtube.com', 'm.youtube.com', 'youtu.be']
if (whitelist.includes(uri)) {
similar += `\\${urlObj.search}`
} else if (youtube.includes(urlObj.hostname)) {
// extract id and create both links
const matches = url.match(/(https?:\/\/)?((www\.)?(youtube(-nocookie)?|youtube.googleapis)\.com.*(v\/|v=|vi=|vi\/|e\/|embed\/|user\/.*\/u\/\d+\/)|youtu\.be\/)(?<id>[_0-9a-z-]+)/i)
similar = `(http(s)?://)?((www.)?youtube.com/watch\\?v=${matches?.groups?.id}|youtu.be/${matches?.groups?.id})`
similar = `(http(s)?://)?((www.|m.)?youtube.com/(watch\\?v=|v/)${matches?.groups?.id}|youtu.be/${matches?.groups?.id})((\\?|#)%)?`
} else {
similar += '((\\?|#)%)?'
}