Definiteurl ASP to convert relative address to absolute address code _ Application Tips
Source: Internet
Author: User
'==================================================
' Function name: Definiteurl
' Function: Converts a relative address to an absolute address
' Parameter: Primitiveurl------The relative address to convert
' Parameter: Consulturl------Current page address
'==================================================
Function Definiteurl (Byval primitiveurl,byval consulturl)
Dim Contemp,pritemp,pi,ci,priarray,conarray
If primitiveurl= "" or consulturl= "" or primitiveurl= "$False $" or consulturl= "$False $" Then
Definiteurl= "$False $"
Exit Function
End If
If Left (Lcase (Consulturl), 7) <> "http://" Then
Consulturl= "http://" & Consulturl
End If
Consulturl=replace (Consulturl, "\", "/")
Consulturl=replace (Consulturl, "://", ": \ \")
Primitiveurl=replace (Primitiveurl, "\", "/")
If Right (consulturl,1) <> "/" Then
If Instr (Consulturl, "/") >0 Then
If Instr (Consulturl,len (Consulturl)-instrrev (Consulturl, "/"), ".") >0 Then
Else
Consulturl=consulturl & "/"
End If
Else
Consulturl=consulturl & "/"
End If
End If
Conarray=split (Consulturl, "/")
If Left (LCase (Primitiveurl), 7) = "http://" then
Definiteurl=replace (Primitiveurl, "://", ": \ \")
ElseIf Left (primitiveurl,1) = "/" Then
Definiteurl=conarray (0) & Primitiveurl
ElseIf Left (primitiveurl,2) = "./" Then
Primitiveurl=right (Primitiveurl,len (Primitiveurl)-2)
If Right (consulturl,1) = "/" Then
Definiteurl=consulturl & Primitiveurl
Else
Definiteurl=left (Consulturl,instrrev (Consulturl, "/")) & Primitiveurl
End If
ElseIf Left (primitiveurl,3) = ". /"Then
Do While left (primitiveurl,3) = ". /"
Primitiveurl=right (Primitiveurl,len (Primitiveurl)-3)
Pi=pi+1
Loop
For Ci=0 to (Ubound (ConArray) -1-pi)
If definiteurl<> "" Then
Definiteurl=definiteurl & "/" & ConArray (Ci)
Else
Definiteurl=conarray (Ci)
End If
Next
Definiteurl=definiteurl & "/" & Primitiveurl
Else
If Instr (Primitiveurl, "/") >0 Then
Priarray=split (Primitiveurl, "/")
If Instr (Priarray (0), ".") >0 Then
If Right (primitiveurl,1) = "/" Then
Definiteurl= "http:\\" & Primitiveurl
Else
If Instr (Priarray (Ubound (Priarray)-1), ".") >0 Then
Definiteurl= "http:\\" & Primitiveurl
Else
Definiteurl= "http:\\" & Primitiveurl & "/"
End If
End If
Else
If Right (consulturl,1) = "/" Then
Definiteurl=consulturl & Primitiveurl
Else
Definiteurl=left (Consulturl,instrrev (Consulturl, "/")) & Primitiveurl
End If
End If
Else
If Instr (Primitiveurl, ".") >0 Then
If Right (consulturl,1) = "/" Then
If Right (LCase (Primitiveurl), 3) = '. Cn ' or Right (LCase (Primitiveurl), 3) = ' com ' or right (LCase (Primitiveurl), 3) = "NET" or Right (LCase (Primitiveurl), 3) = "org" Then
Definiteurl= "http:\\" & Primitiveurl & "/"
Else
Definiteurl=consulturl & Primitiveurl
End If
Else
If Right (LCase (Primitiveurl), 3) = '. Cn ' or Right (LCase (Primitiveurl), 3) = ' com ' or right (LCase (Primitiveurl), 3) = "NET" or Right (LCase (Primitiveurl), 3) = "org" Then
Definiteurl= "http:\\" & Primitiveurl & "/"
Else
Definiteurl=left (Consulturl,instrrev (Consulturl, "/")) & "/" & Primitiveurl
End If
End If
Else
If Right (consulturl,1) = "/" Then
Definiteurl=consulturl & Primitiveurl & "/"
Else
Definiteurl=left (Consulturl,instrrev (Consulturl, "/")) & "/" & Primitiveurl & "/"
End If
End If
End If
End If
If Left (definiteurl,1) = "/" Then
Definiteurl=right (Definiteurl,len (Definiteurl)-1)
End If
If definiteurl<> "" Then
Definiteurl=replace (Definiteurl, "//", "/")
Definiteurl=replace (Definiteurl, ": \ \", "://")
Else
Definiteurl= "$False $"
End If
End Function
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.