S
Stanimir Stamenkov
The java.net.URI.relativize(java.net.URI) method does its job exactly
as described in the method documentation, but seems it has really no
usage that way.
I want to relativize:
http://www.example.com/path/to/linked_resource
against:
http://www.example.com/path/to/resource
The result from the URI.relativize() method is an absolute URI. It
works as expected only when the path component of the base URI is
prefix of the path of the URI to relativize, i.e. the above base needs
to be:
http://www.example.com/path/to/
Doing this test I've noticed another thing which should be considered
erroneous behavior according to the algorithm to resolve relative URIs.
If the base is:
http://www.example.com/path/to
and the URI to relativize:
http://www.example.com/path/to/linked_resource
the result is still:
linked_resource
while I expect it to be:
to/linked_resource
The documentation for the URI class also describes
While I couldn't figure exactly what's the meaning of the above tests
they both fail using:
u = http://www.example.com/path/to
v = http://www.example.com/path/to/linked_resource
and the first fails when:
u = http://www.example.com/path/to/
v = http://www.example.com/path/to/linked_resource
I've made my tests using the Sun's Java 1.4 on Windows.
as described in the method documentation, but seems it has really no
usage that way.
I want to relativize:
http://www.example.com/path/to/linked_resource
against:
http://www.example.com/path/to/resource
The result from the URI.relativize() method is an absolute URI. It
works as expected only when the path component of the base URI is
prefix of the path of the URI to relativize, i.e. the above base needs
to be:
http://www.example.com/path/to/
Doing this test I've noticed another thing which should be considered
erroneous behavior according to the algorithm to resolve relative URIs.
If the base is:
http://www.example.com/path/to
and the URI to relativize:
http://www.example.com/path/to/linked_resource
the result is still:
linked_resource
while I expect it to be:
to/linked_resource
The documentation for the URI class also describes
Relativization, finally, is the inverse of resolution: For any two
normalized URIs u and v,
u.relativize(u.resolve(v)).equals(v) and
u.resolve(u.relativize(v)).equals(v) .
While I couldn't figure exactly what's the meaning of the above tests
they both fail using:
u = http://www.example.com/path/to
v = http://www.example.com/path/to/linked_resource
and the first fails when:
u = http://www.example.com/path/to/
v = http://www.example.com/path/to/linked_resource
I've made my tests using the Sun's Java 1.4 on Windows.