modified regex
- it matched "www.google" which shouldnt be possible
This commit is contained in:
parent
611f9ecc5f
commit
b717bd96b1
1 changed files with 2 additions and 1 deletions
|
|
@ -2,7 +2,8 @@ document.getElementById("urlInput").addEventListener("input", function() {
|
|||
const urlInput = document.getElementById("urlInput");
|
||||
const shortenButton = document.getElementById("shortenButton");
|
||||
|
||||
const urlPattern = /^(https?:\/\/)?([\w\d-]+\.)+[a-z]{2,6}(\/[\w\d-]*)*\/?$/i;
|
||||
const urlPattern = /(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})/i
|
||||
|
||||
const isValid = urlPattern.test(urlInput.value);
|
||||
|
||||
if (isValid) {
|
||||
|
|
|
|||
Reference in a new issue