When I do
let baseUrl = URL(string: "ftp://www.foobar.com/foo/bar/")
let finalUrl = URL(string: "//barfoo.com/bar/foo", relativeTo: baseUrl)
print(finalUrl?.absoluteString ?? "ooops")
it prints ftp://barfoo.com/bar/foo
Is this expected behaviour? Is this documented somewhere?
[EDIT] I was just wondering, because I'd expect that all the stuff, including server and path would be taken from the base url, like here:
let baseUrl = URL(string: "ftp://www.foobar.com/foo/bar/")
let finalUrl = URL(string: "boo/far", relativeTo: baseUrl)
print(finalUrl?.absoluteString ?? "ooops")
which prints ftp://www.foobar.com/foo/bar/boo/far
.
Why is the server and everything else from the base url being ignored in the first example? Is that due to the //
at the beginning? And is this part of some RFC or something or documented somewhere else?