Ok, from what I found isValid doesn't look for all protocols specified
in the url RFC so I don't really want to rely on that.

My idea:

1. check the string to see if it only contains alpha and numerical
characters. This way I know if it's just a string like 'ksdfjk3490'

that's not a url. if it was an ip, it would have '.', and the only
possibility i could think of was someone using netbios names or local
host names like computer1 computer2 etc. but in that case i'd expect
http://computer1

If this fails, disqualify the string. remind user to put protocol in
string like http://computer1.com

2. If step 1 passes, check the string to make sure that the leading
characters are one of the following

http://
https://
ftp://
afs://
telnet://
gopher://
nntp:
news:
mailto:

and if one of those is found, pass it as a valid url. there's a lot of
possibilities so rather than be restrictive i'm just going to check
for a valid protocol.

if one is not found, I'm going to assume http:// and add it to the
string. I want all of my redirects in the database to have their
proper prefix so that there are no redirection issues.

However, I tried the following code. I've had a long day, so maybe i'm
overlookign something simple.

<CFIF refindnocase("http://","#redirect_url#",1)
AND refindnocase("https://","#redirect_url#",1)
AND refindnocase("ftp://","#redirect_url#",1)
AND refindnocase("mailto:","#redirect_url#",1)
AND refindnocase("gopher://","#redirect_url#",1)
AND refindnocase("nntp:","#redirect_url#",1)
AND refindnocase("news:","#redirect_url#",1)
AND refindnocase("afs://","#redirect_url#",1)
AND refindnocase("telnet://","#redirect_url#",1)>
        <CFSET redirect_url = "http://"&#redirect_url#>
</CFIF>



if the string already has http://, it doesn't add anything.

if the string doesn't have a prefix, it adds http://

if the string has any of the other prefixes, it adds http://

-- 
Open BlueDragon Public Mailing List
 http://www.openbluedragon.org/   http://twitter.com/OpenBlueDragon
 mailing list - http://groups.google.com/group/openbd?hl=en

 !! save a network - please trim replies before posting !!

Reply via email to