dating a minor illegal - Validating url in javascript

Replicates the functionality of Richard Sonnen [email protected] module : code here into a nodejs module. All functions return an untainted value if the test passes, and undef if it fails.

(copied from original perl module) This module collects common URI validation routines to make input validation, and untainting easier and more readable.

I think it's due to the repeated case insensitive sets in code like .

Take out the 'i' and it doesn't hang but will of course not work as desired.

It's been broken up into separate tests to avoid Reg Ex redos which can be exploited for DOS attacks (I don't think you have to worry about that with client side js, but you do have to worry about your page hanging for so long that your visitor leaves your site).

There is one other repository I've seen that may even be better for is URL at dperini/regex-weburl.js, but it is highly complex.

sa=i&rct=j&q=&esrc=s&source=images&cd=&docid=n Iv5rk2Gy P3h XM&tbnid=isi Ok Me3n Ctex M:&ved=0CAUQj Rw&url= ZXU_2f GKb Ms QTf4YLg AQ&bvm=bv.65177938,d.a Wc&psig=AFQj CNEp Bf Knal9k U7Zu4n7Rn Et2ner N4g&ust=1398298682009707', true]); tests.push(['https://stackoverflow.com/', true]); tests.push(['https://w', false]); tests.push(['aaa', false]); tests.push(['aaaa', false]); tests.push(['oh.my', true]); tests.push(['dfdsfdsfdfdsfsdfs', false]); tests.push(['uk', true]); tests.push(['test-domain.

MUSEUM', true]); tests.push(['tr', false]); tests.push(['hyphen-end-.com', false]); tests.push(['https://sdfasdp.international', true]); tests.push(['https://sdfasdp.pppppppp', false]); tests.push(['https://sdfasdp.ppppppppppppppppppp', false]); tests.push(['https://sdfasd', false]); tests.push(['https://sub1.1234.sub3.sub4.sub5uk/?It's been pointed out in some of the comments, but most probably haven't entered a bad value to see it.Hanging like that makes that code unusable in any serious application.But even with the ignore case flag those tests reject high unicode values that are allowed.The best already mentioned is: That comes from Github segmentio/is-url.Regarding the single word url on the question 'stackoverflow' it will lead me to In my case my only requirement is that the user input won't be interpreted as a relative link when placed in the href of an a tag and the answers here were either a bit OTT for that or allowed URLs not meeting my requirements, so this is what I'm going with: I think using the native URL API is better than a complex regex patterns as @pavlo suggested.

Tags: , ,