Join parts of a URL - joinpath?

URL joining is a bit more complicated, for example:

joinurl("https://example.com/", "http://foo.bar/") == "http://foo.bar/"
joinurl("https://example.com/a/b", "..") == "https://example.com/a"
joinurl("https://example.com/a/b", "c") == "https://example.com/a/b/c"
joinurl("https://example.com/a/b", "/c") == "https://example.com/c"
joinurl("https://example.com/a/b?x=1", "c") == "https://example.com/a/b/c"
4 Likes