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
4 changed files with 7 additions and 3 deletions

View File

@@ -143,7 +143,7 @@ window.qBittorrent.Misc = (function() {
* JS counterpart of the function in src/misc.cpp
*/
const parseHtmlLinks = function(text) {
const exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/ig;
const exp = /(\b(https?|ftp|file):\/\/[-\w+&@#/%?=~|!:,.;]*[-\w+&@#/%=~|])/gi;
return text.replace(exp, "<a target='_blank' rel='noopener noreferrer' href='$1'>$1</a>");
};