Skip to content

Commit 0efed26

Browse files
authored
Merge pull request #3 from UnityTech/bugfix/private-ip-0.0.0.0
treat 0.0.0.0 as a private ip
2 parents c8b4b83 + f834639 commit 0efed26

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

test/validators.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,8 @@ describe('Validators', function () {
414414
, 'http://172.16.10.1/'
415415
, 'http://10.0.0.1/'
416416
, 'http://169.254.169.254/'
417+
, 'http://0.0.0.0/'
418+
, 'http://0.00.000.000/'
417419
, 'http://localhost/'
418420
]
419421
});
@@ -525,6 +527,7 @@ describe('Validators', function () {
525527
validator: 'isPrivateIP'
526528
, valid: [
527529
'127.0.0.1'
530+
, '0.0.0.0'
528531
, '10.0.0.1'
529532
, '172.16.8.1'
530533
, '192.168.0.1'
@@ -536,7 +539,6 @@ describe('Validators', function () {
536539
, invalid: [
537540
'abc'
538541
, '256.0.0.0'
539-
, '0.0.0.0'
540542
, '1.2.3.4'
541543
, '0.0.0.256'
542544
, '26.0.0.256'

validator.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,8 @@
375375
/^192\.168\.([0-9]{1,3})\.([0-9]{1,3})/.test(str) ||
376376
/^172\.(1[6-9]|2\d|30|31)\.([0-9]{1,3})\.([0-9]{1,3})/.test(str) ||
377377
/^127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/.test(str) ||
378-
/^169\.254\.([0-9]{1,3})\.([0-9]{1,3})/.test(str);
378+
/^169\.254\.([0-9]{1,3})\.([0-9]{1,3})/.test(str) ||
379+
/^0{1,3}\.0{1,3}\.0{1,3}\.0{1,3}/.test(str);
379380
}
380381
else if(version === '6') {
381382
return /^fc00:/.test(str) || /^fe80:/.test(str) ||

0 commit comments

Comments
 (0)