Index: java/org/apache/commons/httpclient/URI.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/URI.java,v retrieving revision 1.40 diff -u -r1.40 URI.java --- java/org/apache/commons/httpclient/URI.java 1 Aug 2003 23:18:47 -0000 1.40 +++ java/org/apache/commons/httpclient/URI.java 22 Sep 2003 02:52:04 -0000 @@ -611,6 +611,9 @@ this._fragment = relative._fragment; } this.setURI(); + // reparse the newly built URI, this will ensure that all flags are set correctly. + // TODO there must be a better way to do this + parseUriReference(new String(_uri), true); } // --------------------------------------------------- Instance Variables Index: test/org/apache/commons/httpclient/TestURI.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestURI.java,v retrieving revision 1.5 diff -u -r1.5 TestURI.java --- test/org/apache/commons/httpclient/TestURI.java 19 Jul 2003 09:41:38 -0000 1.5 +++ test/org/apache/commons/httpclient/TestURI.java 22 Sep 2003 02:52:09 -0000 @@ -85,6 +85,33 @@ return new TestSuite(TestURI.class); } + public void testIPv4Address() throws URIException { + + URI base = new URI("http://10.0.1.10:8830", false); + + URI uri = base; + assertTrue("Should be an IPv4 address", uri.isIPv4address()); + + uri = new URI(base, "/04-1.html", false); + assertTrue("Should be an IPv4 address", uri.isIPv4address()); + + uri = new URI("/04-1.html", false); + assertFalse("Should NOT be an IPv4 address", uri.isIPv4address()); + + uri = new URI(base, "http://10.0.1.10:8830/04-1.html", false); + assertTrue("Should be an IPv4 address", uri.isIPv4address()); + + uri = new URI("http://10.0.1.10:8830/04-1.html", false); + assertTrue("Should be an IPv4 address", uri.isIPv4address()); + + uri = new URI(base, "http://host.org/04-1.html", false); + assertFalse("Should NOT be an IPv4 address", uri.isIPv4address()); + + uri = new URI("http://host.org/04-1.html", false); + assertFalse("Should NOT be an IPv4 address", uri.isIPv4address()); + + } + /** * Tests the URI(URI, String) constructor. This tests URIs ability to * resolve relative URIs.