diff --git a/api/resolvers/item.js b/api/resolvers/item.js index 4d95350e..52cb22a3 100644 --- a/api/resolvers/item.js +++ b/api/resolvers/item.js @@ -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\/)(?[_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 += '((\\?|#)%)?' }