From f47af5a13957f6cf94df9f33a12a80f1efe9dfa3 Mon Sep 17 00:00:00 2001 From: Boyan Date: Sun, 8 Dec 2024 00:21:07 +0100 Subject: [PATCH] fixed validation --- src/static/js/validLink.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/static/js/validLink.js b/src/static/js/validLink.js index eb37070..596758c 100644 --- a/src/static/js/validLink.js +++ b/src/static/js/validLink.js @@ -15,12 +15,12 @@ document.addEventListener('DOMContentLoaded', () => { // Function to validate URLs const isValidURL = (url) => { const pattern = new RegExp( - '^(https?:\\/\\/)' + // Protocol (http or https) - '(([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,})' + // Domain name - '(\\:[0-9]{1,5})?' + // Optional port number - '(\\/.*)?$', // Path, query string, or fragment + '^(https?:\\/\\/)?' + // Protocol (http or https) + '(([a-zA-Z0-9_-]+\\.)+[a-zA-Z]{2,6})' + // Domain name + '(\\/[a-zA-Z0-9@:%_\\+.~#?&//==-]*)?$', // Path, query, or fragment (now includes `=`) 'i' - ); + ); + return pattern.test(url); };