ci way to validate url |
[eluser]keevitaja[/eluser]
what is the best practice to validate an url? now the local characters like üõäö etc ara also permitted! any thoughts?
[eluser]keevitaja[/eluser]
this expression doesn't validata IDN urls. so i came up with a solution. i found idn converter from https://github.com/aluksidadi/IDN-Valida....class.php and then extended url helper preg_match validates only the existense of top level domain, cause filter_var passes urls without it. like http://domain Code: function validate_url($url) { if anyone has better solution or approach, i would be glad to hear it!
[eluser]Amitabh Roy[/eluser]
Code: filter_var($url, FILTER_VALIDATE_URL); rejects domain name with dashes even if the domain is valid. There is a bug in php 5.2 which prevents it from validating url with dashes.
[eluser]keevitaja[/eluser]
how about 5.3 bug still present? edit: anyway 5.3.1 validates this one: http://test-öä.ee/this-is-test
[eluser]Amitabh Roy[/eluser]
[quote author="keevitaja" date="1326973473"]how about 5.3 bug still present? edit: anyway 5.3.1 validates this one: http://test-öä.ee/this-is-test[/quote] Great, it works then. Need to add it to my note. |
Welcome Guest, Not a member yet? Register Sign In |