Validating url in javascript

I tried to take into account a number of additional url syntax rules (without getting into internationalisation).

Just imagine you’re doing this before testing modifier to all the regexes to speed up the tests. Here’s a plain text list of all the URLs used in the test. I also don’t want to allow every possible technically valid URL — quite the opposite. See the URL Standard if you’re looking to parse URLs in the same way that browsers do. /anypage'; var str3 = ' var str4 = ' function validate_url(url) alert('This link is ' validate_url(str4)); plugin. You can still customize it upon your requirement (which is to check if the page belongs to twitter or FB). [a-z0-9_] $/i.test(str1)) alert('Str1 has passed first regexp'); if (/https? :\/\/facebook\.com\/[a-z0-9_] $/i.test(str3)) alert('Str3 has passed second regexp'); var str1 = ' var str2 = '