VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



resolve relative link

by RegX (15 Submissions)
Category: Internet/HTML
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

This is a simple function to resolve a relative link. ie turns www.a/b/c/../e.htm into www.a/b/e.htm
Made this for a web crawler I am working on.
Hope you find this usefull.

Rate resolve relative link

Public Function cleanurl(url As String)
Dim x As Long
Dim y As Long
check:
x = InStr(1, url, "../", vbBinaryCompare)
If x = 1 Then
url = Mid(url, 4)
ElseIf x > 1 Then
 y = InStrRev(url, "/", x - 2, vbBinaryCompare)
 If y > 0 Then
 url = Mid(url, 1, y) & Mid(url, x + 3)
 Else
  url = Mid(url, 4)
 Debug.Print url
 End If
GoTo check:
End If
cleanurl = url
End Function

Download this snippet    Add to My Saved Code

resolve relative link Comments

No comments have been posted about resolve relative link. Why not be the first to post a comment about resolve relative link.

Post your comment

Subject:
Message:
0/1000 characters