Hi Dan,
I noticed that the refTo function in uripath.py [1] would return "/x"
when asked the path between "http://example/" and "http://example/x",
while "x" would be a shorter and possibly more useful answer.
Although refTo doesn't say whether it return preferentially absolute or
relative path, (and seems to be doing a bit of two), having it reply
with "x" in this case proves useful to determine that
http://example/#foo doesn't require a new request if you have already
requested http://example/#foo.
The patch attached makes the code behave that way, contains test case,
and passes the existing tests. Is it OK to commit?
Dom
1. http://dev.w3.org/cvsweb/2000/10/swap/uripath.py
--- /usr/local/lib/python2.3/site-packages/swap/uripath.py 2006-04-27 11:16:58.000000000 +0200
+++ uripath.py 2006-06-14 14:35:46.000000000 +0200
@@ -213,7 +213,10 @@
if k<0: k=-2 # no host
l=uri.find("/", k+2)
if uri[l+1:l+2] != "/" and base[l+1:l+2] != "/" and uri[:l]==base[:l]:
- return uri[l:]
+ if "/" in uri[l+1:] or "/" in base[l+1:]:
+ return uri[l:]
+ else:
+ return uri[l+1:]
if uri[i:i+1] =="#" and len(base) == i: return uri[i:] # fragment of base
@@ -297,7 +300,10 @@
("http://example/x/y%2Fz", "http://example/x%2Fabc", "/x%2Fabc"),
("http://example/x%2Fy/z", "http://example/x%2Fy/abc", "abc"),
# Ryan Lee
- ("http://example/x/abc.efg", "http://example/x/", "./")
+ ("http://example/x/abc.efg", "http://example/x/", "./"),
+ # Dom
+ ("http://example/","http://example/x","x"),
+ ("file:/ex","file:/x","x")
)
for inp1, inp2, exp in cases: