Steven D'Aprano writes:
URLs are also a lot more complicated than file paths,
It may be just me, but I would say the opposite: URLs are simpler because they follow unambiguous rules. There is no "realpath" for URLs, they're WYSIWYG. "." and ".." have unambiguous semantics in URLs, which are implementable as string transformations.
so you should be using urllib to assemble the parts:
Following the rules is not entirely trivial, though, so +1000 here.
Footnotes:  Up to server implementation, but that's explicitly out of scope when you're talking about the URL itself.