Absolutising a URI is not just concatenating two paths together.
The details are given in RFC2396. In summary,
-
If the URI has a scheme, it is not a relative URI, and it
is returned unchanged.
-
Otherwise the absolutised URI has the same
scheme as base URI.
-
If the URI has a network address
(// [ user@ ] host [ :port ] ),
the absolutised URI has that network address and
path of the URI. Otherwise it has the network address
of the base.
-
If the URI has a network address and/or it has absolute
path (starts with '/'), this is the path of the
absolutised URI.
-
Otherwise path of base URI up to its last '/'
is concatenated with the path of URI. For
example,
-
relative /a/b/c + base /x/y/z becomes /a/b/c
-
relative a/b/c + base /x/y/z becomes /x/y/a/b/c
-
relative a/b/c + base /x/y/z/ becomes /x/y/z/a/b/c
-
relative ../b/c + base /x/y/z becomes /x/y/../b/c which is reduced to /x/b/c
-
The absolutised parameter, search, and fragment
are those of the URI. (The uri routines regard the
fragment as part of the URI. Officially the
fragment is a separate construct next to the
URI.)