[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
URI Comparisons (something practical)
Has anyone yet tried the equivalence tests implied in RFC2396bis with
the APIs they're using?
For example:
import java.net.URI;
import java.net.URL;
public class URITest {
public static void main(String[] args) {
try {
URL urlA = new URL("http://example.org");
URL urlB = new URL("HTTP://example.org");
System.out.println(urlA.equals(urlB));
URI uriA = new URI("http://example.org");
URI uriB = new URI("HTTP://example.org");
System.out.println(uriA.equals(uriB));
} catch (Exception e) {
e.printStackTrace();
}
}
}
Produces:
true
true
Other comparisons can be seen in PaceCanonicalIds.
I've changed my mind on canonicalization myself once already (it
sounded too much work at first), perhaps there's a way to consensus
through practical code..?
If we mandated char-by-char comparison alone (so HTTP://example.org
not equivalent to http://example.org) then the Java developer couldn't
use the built-in URI/URL classes directly. So (I hear you say) why not
just do .toString() prior to comparison? Well, say I, what about the
normalization of dots and so on? Is this confusing? Would it be any
more work to do this normalization when the ids were generated?
Cheers,
Danny.
--
http://dannyayers.com