commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Reilly" <>
Subject RE: [validator] UrlValidator
Date Mon, 16 Aug 2004 03:23:07 GMT
Thanks Martin!
Then it appears I was using the is validScheme etc incorrectly and as well a
bug. I've open a bugzilla issue for the optional port and path issues.

I have started a patch for this.

Starting with the unit test:
The patch seems easy enough. In the arrays of test parts I'm adding empty
strings such as

-   TestPair[] testPath = {new TestPair("/test1", true),
+   TestPair[] testPath = {new TestPair("", true),
+                          new TestPair("/test1", true),

Question 1)
Which should be valid according to the rfc:
or both perhaps?
I'll adjust the test data accordingly.

Question 2)
On line 206 of UrlTest I'm confused by
new TestPair("", true)};
seems to be constructing a case where scheme may be EMPTY_STRING as valid.
I'd assumed scheme is always required of a url, but admit I've not read the
rfc you mentioned.

Question 3)
Changing the UrlValidator should be a matter of getting the regular
expression correct I believe(?) for the empty path parts.
One thought I had on port validation was to attempt to construct a and do something like

if (u.getPort() < 0 && u.getDefaultPort() < 0) {
    return false;
which I think would mean the protocol handler for the scheme has a known
default port. Does this sound like a good approach? or is there a case where
someone has a protocol handler with default port that wouldn't
know about? Or a case where is going to throw
MalFormedUrlException where UrlValidator.isValid would otherwise return

NP on the 1.1.4 status for me. If getting patches in can get it to 1.1.3
that'd be good too, either way.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message