Skip to content

Commit fcbe17a

Browse files
committed
fix isPort (#2208)
1 parent cb91971 commit fcbe17a

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

src/lib/isInt.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ export default function isInt(str, options) {
99

1010
// Get the regex to use for testing, based on whether
1111
// leading zeroes are allowed or not.
12-
let regex = (
13-
options.hasOwnProperty('allow_leading_zeroes') && !options.allow_leading_zeroes ?
14-
int : intLeadingZeroes
15-
);
12+
const regex = options.allow_leading_zeroes === false ? int : intLeadingZeroes;
1613

1714
// Check min/max/lt/gt
1815
let minCheckPassed = (!options.hasOwnProperty('min') || str >= options.min);

src/lib/isPort.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import isInt from './isInt';
22

33
export default function isPort(str) {
4-
return isInt(str, { min: 0, max: 65535 });
4+
return isInt(str, { allow_leading_zeroes: false, min: 0, max: 65535 });
55
}

test/validators.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2797,6 +2797,7 @@ describe('Validators', () => {
27972797
'',
27982798
'-1',
27992799
'65536',
2800+
'0080',
28002801
],
28012802
});
28022803
});

0 commit comments

Comments
 (0)