WebUI: add linting for regular expressions

And applies to following suggestions:
* Use case-insensitive flag `i`
* Use `\w` for matching characters
* Sort the regex flags
This commit is contained in:
Chocobo1 2024-04-30 01:10:00 +08:00
parent e2d6cd31b2
commit 6231208ddf
No known key found for this signature in database
GPG key ID: 210D9C873253A68C
4 changed files with 7 additions and 3 deletions

View file

@ -1527,8 +1527,8 @@ window.addEventListener("DOMContentLoaded", function() {
return lowercaseStr.startsWith("http:")
|| lowercaseStr.startsWith("https:")
|| lowercaseStr.startsWith("magnet:")
|| ((str.length === 40) && !(/[^0-9A-Fa-f]/.test(str))) // v1 hex-encoded SHA-1 info-hash
|| ((str.length === 32) && !(/[^2-7A-Za-z]/.test(str))); // v1 Base32 encoded SHA-1 info-hash
|| ((str.length === 40) && !(/[^0-9A-F]/i.test(str))) // v1 hex-encoded SHA-1 info-hash
|| ((str.length === 32) && !(/[^2-7A-Z]/i.test(str))); // v1 Base32 encoded SHA-1 info-hash
});
if (urls.length <= 0)