From a7ba5aa8e14f007f1d67df3e05296bea8f69f534 Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Wed, 28 Jun 2023 01:39:35 -0500 Subject: [PATCH] Modified the Regex to accept additional (valid) characters --- index.js | 3 ++- result.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 7c2f8a7..329c99b 100644 --- a/index.js +++ b/index.js @@ -87,7 +87,8 @@ function showPosition(position) { // /* Flag */ // } let valid = true; - const domainExp = new RegExp("^http(s)*:\\/\\/[a-zA-Z0-9\\-]+(\\.[a-zA-Z0-9\\-]+)+$"); +// const domainExp = new RegExp("^http(s)*:\\/\\/[a-zA-Z0-9\\-]+(\\.[a-zA-Z0-9\\-]+)+[_#]*$"); + const domainExp = new RegExp("^http(s)*:\\/\\/[a-zA-Z0-9\\-]+(\\.[a-zA-Z0-9\\-]+)+[\\/_#a-zA-Z0-9\\-]*$"); const filepathExp = new RegExp("^[a-zA-Z]+$"); const glinkExp = new RegExp("^[a-zA-Z]*$"); let glinkStr = glink.value; diff --git a/result.php b/result.php index a231c4e..89638f2 100644 --- a/result.php +++ b/result.php @@ -50,7 +50,7 @@ if ($is_geo == 1) { $longitude = doubleval($longitude); } -$matches = preg_match('/^http(s)*:\\/\\/[a-zA-Z0-9\\-]+(\\.[a-zA-Z0-9\\-]+)+$/',$url); +$matches = preg_match('/^http(s)*:\\/\\/[a-zA-Z0-9\\-]+(\\.[a-zA-Z0-9\\-]+)+[\\/_#a-zA-Z0-9\\-]*$/',$url); if (($matches == 0) || ($matches == false)) { printf("The URL entered was invalid. Please try again."); return;