Search Tools Links Login

resolve relative link

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.

Original Author: RegX


Public Function cleanurl(url As String)
Dim x As Long
Dim y As Long
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)
  url = Mid(url, 4)
Debug.Print url
End If
GoTo check:
End If
cleanurl = url
End Function

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 86 times


Visual Basic 6


No attachments for this post

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.