Hi, I am doing an URL validator. It needs to be the best URL validator I ever made – and it is already quite functional.
I’d be very happy if you’d go there and try to break it and tell me what went wrong if you do break it.
In return you are free to copy the code for your own use.
Usage is very simple, you construct an array with some key/value pairs – look in the source for which value pairs you can use.
Here’s an example from my testapp
/* Make the options */
$options['AssumeProtocol'] = @ $slcAssumeProt;
$options['AllowBracks'] = isset($chkAllowBracks);
@ $chkProthttp ? $options['AllowedProtocols'][] = 'http' : '';
@ $chkProthttps ? $options['AllowedProtocols'][] = 'https' : '';
@ $chkProtmailto ? $options['AllowedProtocols'][] = 'mailto' : '';
@ $chkProtnews ? $options['AllowedProtocols'][] = 'news' : '';
@ $chkProtnntp ? $options['AllowedProtocols'][] = 'nntp' : '';
@ $chkProtgopher ? $options['AllowedProtocols'][] = 'gopher' : '';
@ $chkProttelnet ? $options['AllowedProtocols'][] = 'telnet' : '';
@ $chkProtfile ? $options['AllowedProtocols'][] = 'file' : '';
$options['Require']['Protocol'] = $chkReqProtocol ? true : false;
$options['Require']['User'] = $chkReqUser ? true : false;
$options['Require']['Password'] = $chkReqPassword ? true : false;
$options['Require']['Server'] = $chkReqServer ? true : false;
$options['Require']['Resource'] = $chkReqResource ? true : false;
$options['Require']['TLD'] = $chkReqTLD ? true : false;
$options['Require']['Port'] = $chkReqPort ? true : false;
$options['Require']['QueryString'] = $chkReqQueryString ? true : false;
$options['Require']['Anchor'] = $chkReqAnchor ? true : false;
EWValidator :: _ValURL($URL, $options)








August 16th, 2004 at 8:41 am
It is now very good at http style URL’s. I’ve added a little ’suck up a bunch-o-links from google’ function, and it really seems to validate most of them.
I’ve come to realise that in order to make it that generic validator I dreamt about, I’ll have to branch validation into different schemes. Something I haven’t got the time to do right now.
The tricky part however is doing mangled URLs, I must be very unimaginative, a guy called JetLag gave me some very good malformed URLs, well at least it nails them now