Browse Source

#502: Allowing sites without TLD to pass URI validation, thanks to @troymccabe

phuoc 11 years ago
parent
commit
54bde5a2fd

+ 4 - 0
CHANGELOG.md

@@ -2,6 +2,10 @@
 
 ## v0.5.1 (not released yet)
 
+__Improvements__
+
+* [#502](https://github.com/nghuuphuoc/bootstrapvalidator/pull/502): Allowing sites without TLD to pass URI validation, thanks to [@troymccabe](https://github.com/troymccabe)
+
 __Language Packages__
 
 * [#503](https://github.com/nghuuphuoc/bootstrapvalidator/pull/503): French language package, thanks to [@dlucazeau](https://github.com/dlucazeau)

+ 1 - 0
CONTRIBUTORS.md

@@ -43,6 +43,7 @@ I would like to give big thanks to the following contributors:
 * [@thisisclement](https://github.com/thisisclement)
 * [@tiagofontella](https://github.com/tiagofontella)
 * [@tomByrer](https://github.com/tomByrer)
+* [@troymccabe](https://github.com/troymccabe)
 * [@tureki](https://github.com/tureki)
 * [@vaz](https://github.com/vaz)
 * ... might be you! Let's [fork](https://github.com/nghuuphuoc/bootstrapvalidator/fork) and pull a request!

+ 1 - 1
dist/css/bootstrapValidator.min.css

@@ -2,7 +2,7 @@
  * BootstrapValidator (http://bootstrapvalidator.com)
  * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
  *
- * @version     v0.5.1-dev, built on 2014-07-15 1:16:59 PM
+ * @version     v0.5.1-dev, built on 2014-07-16 5:28:04 AM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT

+ 5 - 2
dist/js/bootstrapValidator.js

@@ -2,7 +2,7 @@
  * BootstrapValidator (http://bootstrapvalidator.com)
  * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
  *
- * @version     v0.5.1-dev, built on 2014-07-15 1:16:59 PM
+ * @version     v0.5.1-dev, built on 2014-07-16 5:28:05 AM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT
@@ -4946,7 +4946,7 @@
             // Notes on possible differences from a standard/generic validation:
             //
             // - utf-8 char class take in consideration the full Unicode range
-            // - TLDs have been made mandatory so single names like "localhost" fails
+            // - TLDs are mandatory unless `allowLocal` is true
             // - protocols have been restricted to ftp, http and https only as requested
             //
             // Changes:
@@ -4956,6 +4956,7 @@
             //   (since they are broadcast/network addresses)
             //
             // - Added exclusion of private, reserved and/or local networks ranges
+            //   unless `allowLocal` is true
             //
             var allowLocal = options.allowLocal === true || options.allowLocal === 'true',
                 urlExp     = new RegExp(
@@ -4987,6 +4988,8 @@
                     "(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*" +
                     // TLD identifier
                     "(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))" +
+                    // Allow intranet sites (no TLD) if `allowLocal` is true
+                    (allowLocal ? '?' : '') +
                     ")" +
                     // port number
                     "(?::\\d{2,5})?" +

File diff suppressed because it is too large
+ 2 - 2
dist/js/bootstrapValidator.min.js


+ 5 - 5
test/spec/validator/uri.js

@@ -2,16 +2,16 @@ describe('uri', function() {
     beforeEach(function () {
         $([
             '<form class="form-horizontal" id="uriForm">',
-            '<div id="msg"></div>',
-            '<div class="form-group">',
-            '<input type="text" name="uri" data-bv-uri />',
-            '</div>',
+                '<div id="msg"></div>',
+                '<div class="form-group">',
+                    '<input type="text" name="uri" data-bv-uri />',
+                '</div>',
             '</form>'
         ].join('\n')).appendTo('body');
 
         $('#uriForm').bootstrapValidator();
 
-        this.bv    = $('#uriForm').data('bootstrapValidator');
+        this.bv   = $('#uriForm').data('bootstrapValidator');
         this.$uri = this.bv.getFieldElements('uri');
     });