Formatremoteurl function of the ASP implementation format into the current Web site complete url-the relative address to the absolute address of the code _ application Tips

Source: Internet
Author: User
Tags trim
'================================================
' Function name: Formatremoteurl
' function: Format to current Web site complete url-convert relative address to absolute address
' parameter: URL----URL string
' Parameters: Currenturl----URL of course site
' Return value: The URL after the format is taken
'================================================
Public Function Formatremoteurl (ByVal url,byval currenturl)
Dim strURL
If Len (URL) < 2 or len (URL) > 255 Or len (Currenturl) < 2 Then
Formatremoteurl = vbNullString
Exit Function
End If
Currenturl = Trim (replace (replace (Currenturl, "", vbNullString), "" ", vbNullString), vbNewLine, vbNullString), "\", "/"), "|", vbNullString)
URL = Trim (replace (replace (URL, ' ", vbNullString)," "", vbNullString), vbNewLine, vbnullstring), "\", "/"), "|", vbNullString)
If InStr (9, Currenturl, "/") = 0 Then
strURL = Currenturl
Else
strURL = Left (Currenturl, INSTR (9, Currenturl, "/")-1)
End If

If strURL = vbnullstring Then strURL = Currenturl
Select Case Left (LCase (URL), 6)
Case "http:/", "https:", "ftp://", "rtsp:/", "mms://"
Formatremoteurl = URL
Exit Function
End Select

If Left (URL, 1) = "/" Then
Formatremoteurl = strURL & URL
Exit Function
End If

If Left (URL, 3) = "... /"Then
Dim Arrayurl
Dim Arraycurrenturl
Dim arraytemp ()
Dim strtemp
Dim I, n
Dim C, l
n = 0
Arraycurrenturl = Split (Currenturl, "/")
Arrayurl = Split (URL, "... /")
c = UBound (Arraycurrenturl)
L = UBound (arrayurl) + 1

If C > L + 2 Then
For i = 0 to C-l
ReDim Preserve arraytemp (n)
Arraytemp (n) = Arraycurrenturl (i)
n = n + 1
Next
strtemp = Join (Arraytemp, "/")
Else
strtemp = strURL
End If
url = Replace (URL, ".. /", vbNullString)
Formatremoteurl = strtemp & "/" & URL
Exit Function
End If
strURL = Left (Currenturl, InStrRev (Currenturl, "/"))
Formatremoteurl = strURL & Replace (URL, "./", vbNullString)
Exit Function
End Function
Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.