torrent source regex added

This commit is contained in:
Daniel Shleifman
2021-06-09 20:38:00 +03:00
parent 388416289e
commit dcc7061c19
5 changed files with 27 additions and 8 deletions

View File

@@ -21,3 +21,9 @@ export const checkImageURL = async url => {
return false
}
}
const magnetRegex = /magnet:\?xt=urn:[a-z0-9]{20,50}/i
const hashRegex = /\b[0-9a-f]{32}\b|\b[0-9a-f]{40}\b|\b[0-9a-f]{64}\b/i
const torrentRegex = /^.*\.(torrent)$/i
export const chechTorrentSource = source =>
source.match(hashRegex) !== null || source.match(magnetRegex) !== null || source.match(torrentRegex) !== null