commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bspeak...@apache.org
Subject svn commit: r589685 - in /commons/proper/validator/trunk/src: main/java/org/apache/commons/validator/routines/DomainValidator.java test/java/org/apache/commons/validator/routines/DomainValidatorTest.java
Date Mon, 29 Oct 2007 15:39:29 GMT
Author: bspeakmon
Date: Mon Oct 29 08:39:29 2007
New Revision: 589685

URL: http://svn.apache.org/viewvc?rev=589685&view=rev
Log:
- allow case-insensitive TLD matching

Modified:
    commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/DomainValidator.java
    commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/DomainValidatorTest.java

Modified: commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/DomainValidator.java
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/DomainValidator.java?rev=589685&r1=589684&r2=589685&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/DomainValidator.java
(original)
+++ commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/DomainValidator.java
Mon Oct 29 08:39:29 2007
@@ -127,7 +127,7 @@
      * @return true if the parameter is an infrastructure TLD
      */
     public boolean isValidInfrastructureTld(String iTld) {
-        return INFRASTRUCTURE_TLD_LIST.contains(chompLeadingDot(iTld));
+        return INFRASTRUCTURE_TLD_LIST.contains(chompLeadingDot(iTld.toLowerCase()));
     }
 
     /**
@@ -138,7 +138,7 @@
      * @return true if the parameter is a generic TLD
      */
     public boolean isValidGenericTld(String gTld) {
-        return GENERIC_TLD_LIST.contains(chompLeadingDot(gTld));
+        return GENERIC_TLD_LIST.contains(chompLeadingDot(gTld.toLowerCase()));
     }
 
     /**
@@ -149,7 +149,7 @@
      * @return true if the parameter is a country code TLD
      */
     public boolean isValidCountryCodeTld(String ccTld) {
-        return COUNTRY_CODE_TLD_LIST.contains(chompLeadingDot(ccTld));
+        return COUNTRY_CODE_TLD_LIST.contains(chompLeadingDot(ccTld.toLowerCase()));
     }
 
     private String chompLeadingDot(String str) {

Modified: commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/DomainValidatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/DomainValidatorTest.java?rev=589685&r1=589684&r2=589685&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/DomainValidatorTest.java
(original)
+++ commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/DomainValidatorTest.java
Mon Oct 29 08:39:29 2007
@@ -37,6 +37,8 @@
 
         assertTrue("test-domain.com should validate", validator.isValid("test-domain.com"));
         assertTrue("two-letter domain label should validate", validator.isValid("as.uk"));
+
+        assertTrue("case-insensitive ApAchE.Org should validate", validator.isValid("ApAchE.Org"));
     }
 
     public void testInvalidDomains() {
@@ -63,6 +65,10 @@
         // country code TLDs
         assertTrue(".uk should validate as ccTLD", validator.isValidCountryCodeTld(".uk"));
         assertFalse(".org shouldn't validate as ccTLD", validator.isValidCountryCodeTld(".org"));
+
+        // case-insensitive
+        assertTrue(".COM should validate as TLD", validator.isValidTld(".COM"));
+        assertTrue(".BiZ should validate as TLD", validator.isValidTld(".BiZ"));
 
         // corner cases
         assertFalse("invalid TLD shouldn't validate", validator.isValid(".nope"));



Mime
View raw message