Maybe I am blind, or just too dumb to do it, but is there any function in xojo to create an absolute url from a relative url? And if not, does anybody know a plugin doing that?
NSURLMBS or CFURLMBS do that for MacOS.
You can also use CURLSURLMBS/CURLNURLMBS/CURLURLMBS class cross platform.
Thanks a lot, Christian!
Hm… when I have a url “http://domain.com/folder/page1.htm”, and a relative url “page2.htm”, it should create “http://domain.com/folder/page2.htm”, but it creates “http://domain.com/page2.htm”, like the relative url was “/page2.htm”. How can I replace just the page name, and how can I use relative urls like “…/…/page2.htm”?
This works fine:
[code]Dim c As New CURLSURLMBS
// load absolute URL
c.URL = “http://domain.com/folder/page1.htm”
// load relative URL
c.URL = “page2.htm”
// get final URL
MsgBox c.URL[/code]
I think you could probably just do something like this:
dim paths() as String = split(path, /)
Dim urls() as String = split(url, /)
While ubound(paths) > -1
Select case paths(I)
Case .
// ignore this
Case ..
Urls.remove(ubound(urls))
Case Else
Exit while
End Select
Paths.remove(0)
Wend
Dim newurl as String = join(urls, /) + / join(paths, /)
Newurl = replaceall(newurl, //, /)