Skip to content

Instantly share code, notes, and snippets.

@weivall
Created August 9, 2012 15:50
Show Gist options
  • Save weivall/3305323 to your computer and use it in GitHub Desktop.
Save weivall/3305323 to your computer and use it in GitHub Desktop.
isValidURL
function isValidURL(url){
return /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/.test(url);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment