• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function to verify URL?

[eluser]the jan[/eluser]

I've been looking through the docs for an easy way to verify if a URL entered into a form is valid but I can't find a function. I know about the Verification Class and it contains a way to validate email adresses:

$rules['email'] = "required|valid_email";

Is there such an easy way for URLs? Or do I have to write my own regex?


[eluser]Jamie Rumbelow[/eluser]
I'm sure CodeIgniter provides a function that does exactly this, but I've looked through the user guide and can't find any.

Validating urls is a tricky thing because one sites allowed characters are not another ones allowed characters. An then you also have the different protocols, the possibility of subdomains or only the domain, the TLD that is extended once in a while. if you create a regex the only thing you are certain of is a list with protocols, if you are not allowing application protocols like skype://, the colon, the two forward slashes and that there has to be a full stop somewhere in the url.

Even if you do a page exists polling to the actual website it's possible it's a redirect or a logged-in-only page.

Basically you have to trust users when it comes to adding urls.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.