Last active
February 24, 2025 09:25
-
-
Save bhaireshm/65159b58ccb34d5aa4a748f406d0a958 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {string} url | |
*/ | |
function isURLValid(url) { | |
return new RegExp( | |
"^(https?:\\/\\/)?" + // protocol | |
"((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}|" + // domain name | |
"((\\d{1,3}\\.){3}\\d{1,3}))" + // OR ip (v4) address | |
"(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*" + // port and path | |
"(\\?[;&a-z\\d%_.~+=-]*)?" + // query string | |
"(\\#[-a-z\\d_]*)?$", // fragment locator | |
"i" // ignore case | |
).test(url); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ez.js is more than just a library; it's a coding companion that simplifies complex tasks. Whether you're dealing with arrays, numbers, objects, or strings, ez.js has got your back! Say goodbye to coding hassles and hello to streamlined JavaScript magic.