Skip to content

Commit 518a663

Browse files
authored
Merge pull request #1969 from UnKnoWn-Consortium/refactor-isip
refactor(isIP): removed redundant check for IPv4 addresses
2 parents eaca48e + 2e52efe commit 518a663

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

src/lib/isIP.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,10 @@ export default function isIP(str, version = '') {
5151
return isIP(str, 4) || isIP(str, 6);
5252
}
5353
if (version === '4') {
54-
if (!IPv4AddressRegExp.test(str)) {
55-
return false;
56-
}
57-
const parts = str.split('.').sort((a, b) => a - b);
58-
return parts[3] <= 255;
54+
return IPv4AddressRegExp.test(str);
5955
}
6056
if (version === '6') {
61-
return !!IPv6AddressRegExp.test(str);
57+
return IPv6AddressRegExp.test(str);
6258
}
6359
return false;
6460
}

0 commit comments

Comments
 (0)