From 1f4488c5687325ba2d8eee7f3aa5280f262ae838 Mon Sep 17 00:00:00 2001 From: Boyan Date: Sun, 8 Dec 2024 00:19:10 +0100 Subject: [PATCH] Update validation --- src/static/js/validLink.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/static/js/validLink.js b/src/static/js/validLink.js index 58538f8..eb37070 100644 --- a/src/static/js/validLink.js +++ b/src/static/js/validLink.js @@ -15,13 +15,15 @@ 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,6})' + // Domain name - '(\\/[a-zA-Z0-9@:%_\\+.~#?&//=]*)?$', // Path, query, or fragment + '^(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 'i' ); return pattern.test(url); }; + // Function to add https:// if missing const addHttpsIfMissing = (url) => {