We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d102fa2 commit dc32290Copy full SHA for dc32290
packages/regex/src/index.ts
@@ -54,6 +54,13 @@ const v6 = `
54
.replace(/\n/g, '')
55
.trim()
56
57
+// Pasted from `cidr-regex` package (https://github.com/silverwind/cidr-regex/blob/master/index.js)
58
+const cidrv4 = `${v4}\\/(3[0-2]|[12]?[0-9])`
59
+const cidrv6 = `${v6}\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])`
60
+
61
export const ip = new RegExp(`^(?:${v4}|${v6})$`)
62
export const ipv4 = new RegExp(`^${v4}$`)
63
export const ipv6 = new RegExp(`^${v6}$`)
64
+export const ipCidr = new RegExp(`(?:^${cidrv4}$)|(?:^${cidrv6}$)`)
65
+export const ipv4Cidr = new RegExp(`^${cidrv4}$`)
66
+export const ipv6Cidr = new RegExp(`^${cidrv6}$`)
0 commit comments