Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
commit patch 15476572
  • Loading branch information
TL-Yao committed Aug 8, 2024
commit 22bb5f474d62932178bbf69f5e0cf54e3b3e58da
2 changes: 1 addition & 1 deletion src/additional/url2.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ $.extend( $.validator, {
// https://gist.github.com/dperini/729294
// see also https://mathiasbynens.be/demo/url-regex
// modified to allow protocol-relative URLs
return this.optional( element ) || /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?$/i.test( value );
return this.optional( element ) || /^(?:(?:(?:https?|ftp):)?\/\/)(?:(?:[^\]\[?\/<~#`!@$^&*()+=}|:";',>{ ]|%[0-9A-Fa-f]{2})+(?::(?:[^\]\[?\/<~#`!@$^&*()+=}|:";',>{ ]|%[0-9A-Fa-f]{2})*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?$/i.test( value );
},

// https://jqueryvalidation.org/date-method/
Expand Down
4 changes: 2 additions & 2 deletions test/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ QUnit.test( "url2 (tld optional)", function( assert ) {
assert.ok( method( "http://www.føtex.dk/" ), "Valid url, danish unicode characters" );
assert.ok( method( "http://bösendorfer.de/" ), "Valid url, german unicode characters" );
assert.ok( method( "http://142.42.1.1" ), "Valid IP Address" );
assert.ok( method( "http://bassistance" ), "Valid URL (optional TLD)" );
assert.ok( method( "http://bassistance." ), "Valid URL (optional TLD)" );
assert.ok( !method( "http://192.168.8." ), "Invalid IP Address" );
assert.ok( method( "http://bassistance" ), "Invalid url" );
assert.ok( method( "http://bassistance." ), "Invalid url" );
assert.ok( !method( "http://bassistance,de" ), "Invalid url" );
assert.ok( !method( "http://bassistance;de" ), "Invalid url" );
assert.ok( !method( "http://.bassistancede" ), "Invalid url" );
Expand Down