Skip to content

Commit dad7125

Browse files
Potential fix for code scanning alert no. 475: Inefficient regular expression
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 08a34fd commit dad7125

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

scripts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ function validateIP (ip) {
9595

9696
// Validate URL
9797
function validateURL (url) {
98-
const regex = /^(https?:\/\/)?[A-Za-z0-9_.-]+(\.[A-Za-z0-9_.-]+)+[/#?]?.*$/
98+
const regex = /^(https?:\/\/)?[A-Za-z0-9](?:[A-Za-z0-9_.-]*[A-Za-z0-9])?(\.[A-Za-z0-9](?:[A-Za-z0-9_.-]*[A-Za-z0-9])?)+[/#?]?.*$/
9999
return regex.test(url)
100100
}
101101

0 commit comments

Comments
 (0)