Skip to content

Commit 90c19e8

Browse files
ShreySinha02shreysinha25rubiin
authored
fix(isIP): improve IPv6 regex (#2453)
* fix #2039 * remove line and add test to isIp.test.js * change isIp --------- Co-authored-by: shreysinha25 <[email protected]> Co-authored-by: Rubin Bhandari <[email protected]>
1 parent b610a88 commit 90c19e8

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/lib/isIP.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const IPv6AddressRegExp = new RegExp('^(' +
4242
`(?:${IPv6SegmentFormat}:){2}(?:(:${IPv6SegmentFormat}){0,3}:${IPv4AddressFormat}|(:${IPv6SegmentFormat}){1,5}|:)|` +
4343
`(?:${IPv6SegmentFormat}:){1}(?:(:${IPv6SegmentFormat}){0,4}:${IPv4AddressFormat}|(:${IPv6SegmentFormat}){1,6}|:)|` +
4444
`(?::((?::${IPv6SegmentFormat}){0,5}:${IPv4AddressFormat}|(?::${IPv6SegmentFormat}){1,7}|:))` +
45-
')(%[0-9a-zA-Z-.:]{1,})?$');
45+
')(%[0-9a-zA-Z.]{1,})?$');
4646

4747
export default function isIP(ipAddress, options = {}) {
4848
assertString(ipAddress);

test/validators/isIP.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ describe('isIP', () => {
7070
'2001:db8:0000:1:1:1:1::1',
7171
'0:0:0:0:0:0:ffff:127.0.0.1',
7272
'0:0:0:0:ffff:127.0.0.1',
73+
'BC:e4d5:c:e7b9::%40i0nccymtl9cwfKo.5vaeXLSGRMe:EDh2qs5wkhnPws5xQKqafjfAMm6wGFCJ.bVFsZfb',
74+
'1dC:0DF8:62D:3AC::%KTatXocjaFVioS0RTNQl4mA.V151o0RSy.JIu-D-D8.d3171ZWsSJ7PK4YjkJCRN0F',
7375
],
7476
});
7577

0 commit comments

Comments
 (0)