Closed
Bug 290093
Opened 20 years ago
Closed 9 years ago
nsIURL.getRelativeSpec should make it possible to distinguish between a relative file that happens to look like a url and a url that is not relative
Categories
(Core :: Networking, enhancement)
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: timeless, Unassigned)
Details
today's world (as seen from xpcshell)
js>
ios=Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService)
[xpconnect wrapped nsIIOService]
js> fbfb=ios.newURI("http://foo/bar/http://foo/bar",null,null)
[xpconnect wrapped nsIURI]
js> fb=ios.newURI("http://foo/bar/",null,null)
[xpconnect wrapped nsIURI]
js> fb instanceof Components.interfaces.nsIURL
true
js> fbfb instanceof Components.interfaces.nsIURL
true
js> fb
[xpconnect wrapped (nsISupports, nsIURI, nsIURL)]
js> fbfb.getRelativeSpec(fb)
../../../
js> fbfb.spec
http://foo/bar/http://foo/bar
js> fb.getRelativeSpec(fbfb)
http://foo/bar
js> bz=ios.newURI("http://baz/bar/",null,null)
[xpconnect wrapped nsIURI]
js> bz instanceof Components.interfaces.nsIURL
true
js> fb.getRelativeSpec(bz)
http://baz/bar/
js> fb.getRelativeSpec(fbfb)
http://foo/bar
js> [fbfb.spec,fb.spec,bz.spec,fb.getRelativeSpec(bz),fb.getRelativeSpec(fbfb)]
http://foo/bar/http://foo/bar,http://foo/bar/,http://baz/bar/,http://baz/bar/,http://foo/bar
js> [fbfb.spec,fb.spec,bz.spec,fb.getRelativeSpec(bz),fb.getRelativeSpec(fbfb)]
http://foo/bar/http://foo/bar,http://foo/bar/,http://baz/bar/,http://baz/bar/,http://foo/bar
js> fb.getRelativeSpec(fb)
js> bz.getRelativeSpec(fb)
http://foo/bar/
js> fb.getRelativeSpec(fbfb)
http://foo/bar
js> fbfb.getRelativeSpec(fb)
../../../
the problem is of course there's no way to distinguish between
fb.getRelativeSpec(bz) and fb.getRelativeSpec(fbfb).
js> qua=ios.newURI("http://foo/bar/a?hi",null,null)
[xpconnect wrapped nsIURI]
js> fba=ios.newURI("http://foo/bar/a",null,null)
[xpconnect wrapped nsIURI]
js> fba instanceof Components.interfaces.nsIURL
true
js> fba.getRelativeSpec(qua)
a?hi
js> fba.spec
http://foo/bar/a
biesi and i favor prepending ./ for files/directories that are strictly children
of this. with that change:
js> fb.getRelativeSpec(bz)
http://baz/bar/
js> fb.getRelativeSpec(fbfb)
./http://foo/bar
js> fba.getRelativeSpec(qua)
./a?hi
an alternative which i dislike would be to escape ':', this kinda sucks for
%2542, because i'd have to know to just unescape the first %3A, and i will want
to just present the strings to a user to read, the user will not appreciate %3A
or a rule that says "the first %3A is magical".
Updated•19 years ago
|
Assignee: darin → nobody
QA Contact: benc → networking
Updated•9 years ago
|
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•