mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-22 16:37:21 -06:00
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:
@@ -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)
|
||||
|
||||
@@ -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>");
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user