Skip to content

Instantly share code, notes, and snippets.

@bhaireshm
Last active February 24, 2025 09:25
Show Gist options
  • Select an option

  • Save bhaireshm/65159b58ccb34d5aa4a748f406d0a958 to your computer and use it in GitHub Desktop.

Select an option

Save bhaireshm/65159b58ccb34d5aa4a748f406d0a958 to your computer and use it in GitHub Desktop.
/**
* @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);
}
@bhaireshm

Copy link
Copy Markdown
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment