This function supports these forms of relative URLs:
- ^\w+: Absolute URL. E.g. "http://www.example.com:port/path?query#fragment".
- ^// Same protocol. E.g. "//www.example.com:port/path?query#fragment"
- ^/ Same protocol and host. E.g. "/path?query#fragment".
- ^? Same protocol, host and path, replace query string & fragment. E.g. "?query#fragment".
- ^# Same protocol, host, path and query, replace fragment. E.g. "#fragment".
- The rest: Relative to the base path.