{"_id":"cidr-regex@7.1.0","dist":{"shasum":"f3303caaae8a5ede6c76dfa1466fc00a5e31a327","tarball":"http://registry-npm.ywwl.com/cidr-regex/download/cidr-regex-7.1.0.tgz","fileCount":5,"integrity":"sha512-BQ5X/OTeC6hrD7k8/rNY93etXfQ3mcjIiYOkYDrB5oThXyOrgoa/jgeQxVglQaDA7UrtEnSEpHBqpfuyriwXsQ==","signatures":[{"sig":"MEUCIQCcLA0ucc1YqMv6Kzcc45c2XqEQoTxlaQxjjUxekKWRpAIgBG0FR3zY3KkhCm8t11hdXJZNB/6Ze/yDMI+IKRpXsnk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC7eULGhZn4a76ZhbnKuYwbM/Xcj6Lx3f0UaZXC5ruTMQIgHww3wb9mFXcY2AkYHpI4fyor4eE6yPMLKXj8Ie8thcI="}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/cidr-regex@7.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":8230,"size":3321,"noattachment":false,"key":"/cidr-regex/-/cidr-regex-7.1.0.tgz"},"main":"./dist/index.js","name":"cidr-regex","type":"module","types":"./dist/index.d.ts","author":"silverwind <me@silverwind.io>","engines":{"node":">=22"},"exports":"./dist/index.js","license":"BSD-2-Clause","version":"7.1.0","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:bc42cc8a-dde2-49b5-82f8-03be9f93f649"}},"keywords":["cidr","regex","regexp","ip","ipv4","ipv6","address","subnet","network","notation","match"],"repository":{"url":"silverwind/cidr-regex","type":"git"},"description":"Regular expression for matching IP addresses in CIDR notation and bare IP addresses","directories":{},"maintainers":[{"name":"silverwind","email":"npm@silverwind.io"}],"sideEffects":false,"_nodeVersion":"26.7.0","contributors":["Felipe Apostol <flipjs.io@gmail.com> (http://flipjs.io/)"],"_hasShrinkwrap":false,"devDependencies":{"eslint":"10.8.1","tsdown":"0.22.14","vitest":"4.1.11","updates":"18.0.1","versions":"15.3.4","typescript":"6.0.3","@types/node":"26.2.0","jest-extended":"7.0.0","eslint-config-silverwind":"144.0.2","tsdown-config-silverwind":"4.0.3","vitest-config-silverwind":"11.6.0","updates-config-silverwind":"4.0.5","@typescript/native-preview":"7.0.0-dev.20260707.2","typescript-config-silverwind":"20.0.3"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cidr-regex_7.1.0_1787078670023_0.7584757594632832"},"readme":"# cidr-regex\n[![](https://img.shields.io/npm/v/cidr-regex.svg?style=flat)](https://www.npmjs.org/package/cidr-regex) [![](https://img.shields.io/npm/dm/cidr-regex.svg)](https://www.npmjs.org/package/cidr-regex) [![](https://packagephobia.com/badge?p=cidr-regex)](https://packagephobia.com/result?p=cidr-regex) [![](https://depx.co/api/badge/cidr-regex)](https://depx.co/pkg/cidr-regex)\n\n> Regular expression for matching IP addresses in CIDR notation and bare IP addresses\n\n## Usage\n\n```sh\n$ npm i cidr-regex\n```\n\n```js\nimport cidrRegex from \"cidr-regex\";\n\n// Contains a CIDR IP address?\ncidrRegex().test(\"foo 192.168.0.1/24\");\n//=> true\n\n// Is a CIDR IP address?\ncidrRegex({exact: true}).test(\"foo 192.168.0.1/24\");\n//=> false\n\ncidrRegex.v6({exact: true}).test(\"1:2:3:4:5:6:7:8/64\");\n//=> true\n\n// Extract CIDRs from string\n\"foo 192.168.0.1/24 bar 1:2:3:4:5:6:7:8/64 baz\".match(cidrRegex());\n//=> [\"192.168.0.1/24\", \"1:2:3:4:5:6:7:8/64\"]\n\n// Is a bare IP address?\ncidrRegex({exact: true, prefix: \"none\"}).test(\"192.168.0.1\");\n//=> true\n\n// Is either?\ncidrRegex({exact: true, prefix: \"optional\"}).test(\"192.168.0.1\");\n//=> true\ncidrRegex({exact: true, prefix: \"optional\"}).test(\"192.168.0.1/24\");\n//=> true\n```\n\n## API\n\nAll three functions match CIDR notation by default. The `prefix` option switches them to bare IP addresses or to either.\n\n### cidrRegex(options?: CidrRegexOptions)\n\nReturns a regex for matching both IPv4 and IPv6 CIDR IP addresses.\n\n### cidrRegex.v4(options?: CidrRegexOptions)\n\nReturns a regex for matching IPv4 CIDR IP addresses.\n\n### cidrRegex.v6(options?: CidrRegexOptions)\n\nReturns a regex for matching IPv6 CIDR IP addresses.\n\n#### CidrRegexOptions\n\nThe options object has the following properties:\n\n- `exact` *boolean*: Only match an exact string. Useful with `RegExp#test()` to check if a string is a CIDR IP address. Default: false.\n- `prefix` *string*: Whether a `/prefix` must follow the address. `\"required\"` matches only CIDR, `\"optional\"` matches CIDR and bare IP addresses, `\"none\"` matches only bare IP addresses. Default: `\"required\"`.\n\n## Related\n\n- [ip-bigint](https://github.com/silverwind/ip-bigint) - Convert IPv4 and IPv6 addresses to native BigInt and vice-versa\n- [ip-regex](https://github.com/sindresorhus/ip-regex) - Regular expression for matching IP addresses\n- [is-cidr](https://github.com/silverwind/is-cidr) - Check if a string is an IP address in CIDR notation\n- [is-ip](https://github.com/sindresorhus/is-ip) - Check if a string is an IP address\n- [cidr-tools](https://github.com/silverwind/cidr-tools) - Tools to work with IPv4 and IPv6 CIDR network lists\n\n## License\n\n© [silverwind](https://github.com/silverwind), distributed under BSD licence\n\nBased on previous work by [Felipe Apostol](https://github.com/flipjs)\n","publish_time":1787078670132,"_cnpm_publish_time":1787078670132,"dist-tags":{"latest":"7.1.2"}}