This document has an embedded base URI of
http://a/b/c/d;p?q
the relative URIs should be resolved as shown below.
I will need your help testing the examples on multiple browsers. What you need to do is point to the example anchor and compare it to the resolved URI in your browser (most browsers have a feature by which you can see the resolved URI at the bottom of the window/screen when the anchor is active).
[R] | RFC 3986, STD 66 (the right way to parse) |
[X] | RFC 2396 |
[1] | Mozilla/4.03 [en] (X11; U; SunOS 5.5 sun4u; Nav) |
[2] | Lynx/2.7.1 libwww-FM/2.14 |
[3] | MSIE 3.01; Windows 95 |
[4] | NCSA_Mosaic/2.6 (X11;SunOS 4.1.2 sun4m) libwww/2.12 |
[5] | libwww-perl/5.14 [Martijn Koster] |
[6] | Apple Safari 1.0.2 |
RESULTS from g:h = g:h [R,X,2,3,4,5,6] http://a/b/c/g:h [1] g = http://a/b/c/g [R,X,1,2,3,4,5,6] ./g = http://a/b/c/g [R,X,1,2,3,4,5,6] g/ = http://a/b/c/g/ [R,X,1,2,3,4,5,6] /g = http://a/g [R,X,1,2,3,4,5,6] //g = http://g [R,X,1,2,3,4,5] http://g/ [6] ?y = http://a/b/c/d;p?y [R,5,6] http://a/b/c/?y [X,1,2,3,4] g?y = http://a/b/c/g?y [R,X,1,2,3,4,5,6] #s = http://a/b/c/d;p?q#s [R,X,1,3,5,6] g#s = http://a/b/c/g#s [R,X,1,2,3,4,5,6] g?y#s = http://a/b/c/g?y#s [R,X,1,2,3,4,5,6] ;x = http://a/b/c/;x [R,X,1,2,3,4,6] http://a/b/c/d;x [5] g;x = http://a/b/c/g;x [R,X,1,2,3,4,5,6] g;x?y#s = http://a/b/c/g;x?y#s [R,X,1,2,3,4,5,6] "" = http://a/b/c/d;p?q [R,X,2,3,4,5,6] http://a/b/c/ [1] . = http://a/b/c/ [R,X,2,5,6] http://a/b/c/. [1] http://a/b/c [3,4] ./ = http://a/b/c/ [R,X,1,2,3,4,5,6] .. = http://a/b/ [R,X,2,5,6] http://a/b [1,3,4] ../ = http://a/b/ [R,X,1,2,3,4,5,6] ../g = http://a/b/g [R,X,1,2,3,4,5,6] ../.. = http://a/ [R,X,2,5,6] http://a [1,3,4] ../../ = http://a/ [R,X,1,2,3,4,5,6] ../../g = http://a/g [R,X,1,2,3,4,5,6]
Although the following abnormal examples are unlikely to occur in normal practice, all URI parsers should be capable of resolving them consistently. Each example uses the same base as above.
Parsers must be careful in handling cases where there are more relative path ".." segments than there are hierarchical levels in the base URI's path. Note that the ".." syntax cannot be used to change the authority component of a URI.
../../../g = http://a/g [R,X,1,3,6] http://a/../g [2,4,5] ../../../../g = http://a/g [R,X,1,3,6] http://a/../../g [2,4,5]
Similarly, parsers must remove the dot-segments "." and ".." when they are complete components of a path, but not when they are only part of a segment.
/./g = http://a/g [R,1,6] http://a/./g [X,2,3,4,5] /../g = http://a/g [R,1,6] http://a/../g [X,2,3,4,5] g. = http://a/b/c/g. [R,X,1,2,3,4,5,6] .g = http://a/b/c/.g [R,X,1,2,3,4,5,6] g.. = http://a/b/c/g.. [R,X,1,2,3,4,5,6] ..g = http://a/b/c/..g [R,X,1,2,3,4,5,6]
Less likely are cases where the relative URI reference uses unnecessary or nonsensical forms of the "." and ".." complete path segments.
./../g = http://a/b/g [R,X,1,2,5,6] http://a/b/c/../g [3,4] ./g/. = http://a/b/c/g/ [R,X,2,5,6] http://a/b/c/g/. [1] http://a/b/c/g [3,4] g/./h = http://a/b/c/g/h [R,X,1,2,3,4,5,6] g/../h = http://a/b/c/h [R,X,1,2,3,4,5,6] g;x=1/./y = http://a/b/c/g;x=1/y [R,X,1,2,3,4,6] http://a/b/c/g;x=1/./y [5] g;x=1/../y = http://a/b/c/y [R,X,1,2,3,4,6] http://a/b/c/g;x=1/../y [5]
Some applications fail to separate the reference's query and/or fragment components from a relative path before merging it with the base path and removing dot-segments. This error is rarely noticed, since typical usage of a fragment never includes the hierarchy ("/") character, and the query component is not normally used within relative references.
g?y/./x = http://a/b/c/g?y/./x [R,X,5,6] http://a/b/c/g?y/x [1,2,3,4] g?y/../x = http://a/b/c/g?y/../x [R,X,5,6] http://a/b/c/x [1,2,3,4] g#s/./x = http://a/b/c/g#s/./x [R,X,2,3,4,5,6] http://a/b/c/g#s/x [1] g#s/../x = http://a/b/c/g#s/../x [R,X,2,3,4,5,6] http://a/b/c/x [1]
Some parsers allow the scheme name to be present in a relative URI reference if it is the same as the base URI scheme. This is considered to be a loophole in prior specifications of partial URI [RFC1630]. Its use should be avoided, but is allowed for backward compatibility.
http:g = http:g [R,X,5,6] | http://a/b/c/g [1,2,3,4] (ok for compat.) http: = http: [R,X,5] http://a/b/c/d;p?q [2,3,4] (ok for compat.) http://a/b/c/ [1] http:/ [6]