Initial Commit
[packages] / xemacs-packages / w3 / tests / url-expansion.html
1 <HTML><HEAD>
2 <TITLE>Examples of Resolving Relative URLs</TITLE>
3 <BASE href="http://a/b/c/d;p?q">
4 </HEAD><BODY>
5 <H1>Examples of Resolving Relative URLs</H1>
6
7 This document has an embedded base URL of
8 <PRE>
9    Content-Base: http://a/b/c/d;p?q
10 </PRE>
11 the relative URLs should be resolved as shown below.
12 <P>
13 I will need your help testing the examples on multiple browsers. 
14 What you need to do is point to the example anchor and compare it to the
15 resolved URL in your browser (most browsers have a feature by which you
16 can see the resolved URL at the bottom of the window/screen when the anchor
17 is active).
18
19 <H2>Tested Clients and Client Libraries</H2>
20
21 <DL COMPACT>
22 <DT>[R]
23 <DD>RFC 2396 (the right way to parse)
24 <DT>[X]
25 <DD>RFC 1808
26 <DT>[1]
27 <DD>Mozilla/4.03 [en] (X11; U; SunOS 5.5 sun4u; Nav)
28 <DT>[2]
29 <DD>Lynx/2.7.1 libwww-FM/2.14
30 <DT>[3]
31 <DD>MSIE 3.01; Windows 95
32 <DT>[4]
33 <DD>NCSA_Mosaic/2.6 (X11;SunOS 4.1.2 sun4m) libwww/2.12
34 <DT>[5]
35 <DD>libwww-perl/5.14 [Martijn Koster]
36 </DL>
37
38 <H2>Normal Examples</H2>
39 <PRE>
40               RESULTS                     from
41  
42 <a href="g:h">g:h</a>        =  g:h                         [R,X,2,3,4,5]
43               http://a/b/c/g:h            [1]
44
45 <a href="g">g</a>          =  http://a/b/c/g              [R,X,1,2,3,4,5]
46
47 <a href="./g">./g</a>        =  http://a/b/c/g              [R,X,1,2,3,4,5]
48
49 <a href="g/">g/</a>         =  http://a/b/c/g/             [R,X,1,2,3,4,5]
50
51 <a href="/g">/g</a>         =  http://a/g                  [R,X,1,2,3,4,5]
52
53 <a href="//g">//g</a>        =  http://g                    [R,X,1,2,3,4,5]
54
55 <a href="?y">?y</a>         =  http://a/b/c/?y             [R,1,2,3,4]
56               http://a/b/c/d;p?y          [X,5]
57
58 <a href="g?y">g?y</a>        =  http://a/b/c/g?y            [R,X,1,2,3,4,5]
59
60 <a name="s" href="#s">#s</a>         =  (current document)#s        [R,2,4]
61               http://a/b/c/d;p?q#s        [X,1,3,5]
62
63 <a href="g#s">g#s</a>        =  http://a/b/c/g#s            [R,X,1,2,3,4,5]
64
65 <a href="g?y#s">g?y#s</a>      =  http://a/b/c/g?y#s          [R,X,1,2,3,4,5]
66
67 <a href=";x">;x</a>         =  http://a/b/c/;x             [R,1,2,3,4]
68               http://a/b/c/d;x            [X,5]
69
70 <a href="g;x">g;x</a>        =  http://a/b/c/g;x            [R,X,1,2,3,4,5]
71
72 <a href="g;x?y#s">g;x?y#s</a>    =  http://a/b/c/g;x?y#s        [R,X,1,2,3,4,5]
73
74 <a href=".">.</a>          =  http://a/b/c/               [R,X,2,5]
75               http://a/b/c/.              [1]
76               http://a/b/c                [3,4]
77
78 <a href="./">./</a>         =  http://a/b/c/               [R,X,1,2,3,4,5]
79
80 <a href="..">..</a>         =  http://a/b/                 [R,X,2,5]
81               http://a/b                  [1,3,4]
82
83 <a href="../">../</a>        =  http://a/b/                 [R,X,1,2,3,4,5]
84
85 <a href="../g">../g</a>       =  http://a/b/g                [R,X,1,2,3,4,5]
86
87 <a href="../..">../..</a>      =  http://a/                   [R,X,2,5]
88               http://a                    [1,3,4]
89
90 <a href="../../">../../</a>     =  http://a/                   [R,X,1,2,3,4,5]
91
92 <a href="../../g">../../g</a>    =  http://a/g                  [R,X,1,2,3,4,5]
93 </PRE>
94
95 <H2>Abnormal Examples</H2>
96
97 Although the following abnormal examples are unlikely to occur in
98 normal practice, all URL parsers should be capable of resolving them
99 consistently.  Each example uses the same base as above.<P>
100
101 An empty reference refers to the start of the current document.
102 <PRE>
103 <a href="">&lt;&gt;</a>         =  (current document)          [R,2,4]
104               http://a/b/c/d;p?q          [X,3,5]
105               http://a/b/c/               [1]
106 </PRE>
107 Parsers must be careful in handling the case where there are more
108 relative path ".." segments than there are hierarchical levels in the
109 base URL's path.  Note that the ".." syntax cannot be used to change
110 the site component of a URL.
111 <PRE>
112 <a href="../../../g">../../../g</a>    =  http://a/../g            [R,X,2,4,5]
113                  http://a/g               [R,1,3]
114
115 <a href="../../../../g">../../../../g</a> =  http://a/../../g         [R,X,2,4,5]
116                  http://a/g               [R,1,3]
117 </PRE>
118 In practice, some implementations strip leading relative symbolic
119 elements (".", "..") after applying a relative URL calculation, based
120 on the theory that compensating for obvious author errors is better
121 than allowing the request to fail.  Thus, the above two references
122 will be interpreted as "http://a/g" by some implementations.
123 <P>
124 Similarly, parsers must avoid treating "." and ".." as special when
125 they are not complete components of a relative path.
126 <PRE>
127 <a href="/./g">/./g</a>      =  http://a/./g                 [R,X,2,3,4,5]
128              http://a/g                   [1]
129
130 <a href="/../g">/../g</a>     =  http://a/../g                [R,X,2,3,4,5]
131              http://a/g                   [1]
132
133 <a href="g.">g.</a>        =  http://a/b/c/g.              [R,X,1,2,3,4,5]
134
135 <a href=".g">.g</a>        =  http://a/b/c/.g              [R,X,1,2,3,4,5]
136
137 <a href="g..">g..</a>       =  http://a/b/c/g..             [R,X,1,2,3,4,5]
138
139 <a href="..g">..g</a>       =  http://a/b/c/..g             [R,X,1,2,3,4,5]
140 </PRE>
141 Less likely are cases where the relative URL uses unnecessary or
142 nonsensical forms of the "." and ".." complete path segments.
143 <PRE>
144 <a href="./../g">./../g</a>     =  http://a/b/g                [R,X,1,2,5]
145               http://a/b/c/../g           [3,4]
146
147 <a href="./g/.">./g/.</a>      =  http://a/b/c/g/             [R,X,2,5]
148               http://a/b/c/g/.            [1]
149               http://a/b/c/g              [3,4]
150
151 <a href="g/./h">g/./h</a>      =  http://a/b/c/g/h            [R,X,1,2,3,4,5]
152
153 <a href="g/../h">g/../h</a>     =  http://a/b/c/h              [R,X,1,2,3,4,5]
154
155 <a href="g;x=1/./y">g;x=1/./y</a>  =  http://a/b/c/g;x=1/y        [R,1,2,3,4]
156               http://a/b/c/g;x=1/./y      [X,5]
157
158 <a href="g;x=1/../y">g;x=1/../y</a> =  http://a/b/c/y              [R,1,2,3,4]
159               http://a/b/c/g;x=1/../y     [X,5]
160
161 </PRE>
162 All client applications remove the query component from the base URL
163 before resolving relative URLs.  However, some applications fail to
164 separate the reference's query and/or fragment components from a
165 relative path before merging it with the base path.  This error is
166 rarely noticed, since typical usage of a fragment never includes the
167 hierarchy ("/") character, and the query component is not normally
168 used within relative references.
169 <PRE>
170 <a href="g?y/./x">g?y/./x</a>    =  http://a/b/c/g?y/./x        [R,X,5]
171               http://a/b/c/g?y/x          [1,2,3,4]
172
173 <a href="g?y/../x">g?y/../x</a>   =  http://a/b/c/g?y/../x       [R,X,5]
174               http://a/b/c/x              [1,2,3,4]
175
176 <a href="g#s/./x">g#s/./x</a>    =  http://a/b/c/g#s/./x        [R,X,2,3,4,5]
177               http://a/b/c/g#s/x          [1]
178
179 <a href="g#s/../x">g#s/../x</a>   =  http://a/b/c/g#s/../x       [R,X,2,3,4,5]
180               http://a/b/c/x              [1]
181 </PRE>
182    Some parsers allow the scheme name to be present in a relative URI if
183    it is the same as the base URI scheme.  This is considered to be a
184    loophole in prior specifications of partial URI [RFC1630]. Its use
185    should be avoided.
186 <PRE>
187 <a href="http:g">http:g</a>    =  http:g                       [R,X,5]
188           |  http://a/b/c/g               [1,2,3,4]  (ok for compat.)
189
190 <a href="http:">http:</a>     =  http:                        [R,X,5]
191              http://a/b/c/                [1]
192              http://a/b/c/d;p?q           [2,3,4]
193 </PRE>
194 </BODY></HTML>