I’m working on a function to validate http urls. I need some good and bad urls to do unit testing. Please share me your test cases.
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are many permutations and combinations … also how strictly you are conforming to the standard spec is something to worry about
What are the protocols supported … is it only http … or https, rmtp etc as well
Consider things like domains and subdomains … http://www.google.com and http://www.maps.google.com are valid
Presence or absence of trailing slash
Non-standard port … http://www.example.com:8800
Deep path after the host … http://www.example.com/a/b/c/d/e/f/g/h/i.html
URL Parameters … http://www.test.com?pageid=123&testid=1524
URL encoding … and how are URL are encoded within a URL if they are the part of the parameters
Anchor tags … http://www.test.com/do.html#A
Presence of special characters … if any
handling white spaces
Max and Min size of a URL
Interesting!!
Have you investigated in existing libraries which let you validate the URLs