commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mr...@apache.org
Subject svn commit: r232628 - in /jakarta/commons/proper/validator/trunk/src: share/org/apache/commons/validator/UrlValidator.java test/org/apache/commons/validator/UrlTest.java
Date Sun, 14 Aug 2005 18:30:42 GMT
Author: mrdon
Date: Sun Aug 14 11:30:40 2005
New Revision: 232628

URL: http://svn.apache.org/viewcvs?rev=232628&view=rev
Log:
Changing url validator to accept empty paths and those with a trailing slash
PR: 30686

Modified:
    jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/UrlValidator.java
    jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/UrlTest.java

Modified: jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/UrlValidator.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/UrlValidator.java?rev=232628&r1=232627&r2=232628&view=diff
==============================================================================
--- jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/UrlValidator.java
(original)
+++ jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/UrlValidator.java
Sun Aug 14 11:30:40 2005
@@ -148,7 +148,7 @@
      */
     private static final int PARSE_AUTHORITY_EXTRA = 3;
 
-    private static final String PATH_PATTERN = "/^(/[-\\w:@&?=+,.!/~*'%$]*)$/";
+    private static final String PATH_PATTERN = "/^(/[-\\w:@&?=+,.!/~*'%$]*)?$/";
 
     private static final String QUERY_PATTERN = "/^(.*)$/";
 
@@ -420,10 +420,6 @@
         Perl5Util pathMatcher = new Perl5Util();
 
         if (!pathMatcher.match(PATH_PATTERN, path)) {
-            return false;
-        }
-
-        if (path.endsWith("/")) {
             return false;
         }
 

Modified: jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/UrlTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/UrlTest.java?rev=232628&r1=232627&r2=232628&view=diff
==============================================================================
--- jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/UrlTest.java
(original)
+++ jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/UrlTest.java
Sun Aug 14 11:30:40 2005
@@ -95,6 +95,8 @@
     */
    public void testIsValid(Object[] testObjects, int options) {
       UrlValidator urlVal = new UrlValidator(null, options);
+      assertTrue(urlVal.isValid("http://www.google.com"));
+      assertTrue(urlVal.isValid("http://www.google.com/"));
       int statusPerLine = 60;
       int printed = 0;
       if (printIndex)  {
@@ -237,8 +239,8 @@
                           new TestPair("/$23", true),
                           new TestPair("/..", false),
                           new TestPair("/../", false),
-                          new TestPair("/test1/", false),
-                          new TestPair("", false),
+                          new TestPair("/test1/", true),
+                          new TestPair("", true),
                           new TestPair("/test1/file", true),
                           new TestPair("/..//file", false),
                           new TestPair("/test1//file", false)
@@ -249,9 +251,9 @@
                                     new TestPair("/$23", true),
                                     new TestPair("/..", false),
                                     new TestPair("/../", false),
-                                    new TestPair("/test1/", false),
+                                    new TestPair("/test1/", true),
                                     new TestPair("/#", false),
-                                    new TestPair("", false),
+                                    new TestPair("", true),
                                     new TestPair("/test1/file", true),
                                     new TestPair("/t123/file", true),
                                     new TestPair("/$23/file", true),



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message