{"name":"safe-regex2","version":"5.1.1","keywords":["catastrophic","exponential","regex","safe","sandbox"],"author":{"url":"http://substack.net","name":"James Halliday","email":"mail@substack.net"},"license":"MIT","_id":"safe-regex2@5.1.1","maintainers":[{"name":"zekth","email":"vince.legoff@gmail.com"},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"gurgunday","email":"hey@gurgun.day"},{"name":"ivan-tymoshenko","email":"ivan@tymoshenko.me"},{"name":"simoneb","email":"simone.busoli@gmail.com"},{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"fdawgs","email":"frazer.dev@icloud.com"},{"name":"metcoder95","email":"me@metcoder.dev"},{"name":"matteo.collina","email":"hello@matteocollina.com"}],"contributors":[{"name":"Matteo Collina","email":"hello@matteocollina.com"},{"url":"https://heyhey.to/G","name":"Gürgün Dayıoğlu","email":"hey@gurgun.day"},{"url":"https://james.sumners.info","name":"James Sumners"},{"url":"https://github.com/fdawgs","name":"Frazer Smith","email":"frazer.dev@icloud.com"}],"homepage":"https://github.com/fastify/safe-regex2","bugs":{"url":"https://github.com/fastify/safe-regex2/issues"},"bin":{"safe-regex2":"bin/safe-regex2.js"},"dist":{"shasum":"a5f3a6e35b8d84d0f41fa22efd5b6d30b367bbc7","tarball":"http://registry-npm.ywwl.com/safe-regex2/download/safe-regex2-5.1.1.tgz","fileCount":14,"integrity":"sha512-mOSBvHGDZMuIEZMdOz/aCEYDCv0E7nfcNsIhUF+/P+xC7Hyf3FkvymqgPbg9D1EdSGu+uKbJgy09K/RKKc7kJA==","signatures":[{"sig":"MEUCIQDYxhwd8ioyUstB+bhFBcySUmBk6nHRhHyhFJ/EcHvFDwIgSX8G5d4ecjLCJp3Tt9VqE8MHn+xt3IZS0NusyXHfzaE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11506,"size":4884,"noattachment":false,"key":"/safe-regex2/-/safe-regex2-5.1.1.tgz"},"main":"index.js","type":"commonjs","types":"types/index.d.ts","funding":[{"url":"https://github.com/sponsors/fastify","type":"github"},{"url":"https://opencollective.com/fastify","type":"opencollective"}],"gitHead":"35dd3a751b3362d265adfc30170078667464645e","scripts":{"lint":"eslint","test":"npm run test:unit && npm run test:typescript","lint:fix":"eslint --fix","test:unit":"c8 --100 node --test","test:typescript":"tsd"},"_npmUser":{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},"repository":{"url":"git://github.com/fastify/safe-regex2.git","type":"git"},"_npmVersion":"11.9.0","description":"detect possibly catastrophic, exponential-time regular expressions","directories":{},"_nodeVersion":"24.14.0","dependencies":{"ret":"~0.5.0"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^11.0.0","tsd":"^0.33.0","eslint":"^9.17.0","neostandard":"^0.13.0"},"_npmOperationalInternal":{"tmp":"tmp/safe-regex2_5.1.1_1776573359303_0.025517977198721287","host":"s3://npm-registry-packages-npm-production"},"readme":"# safe-regex2\n\n[![CI](https://github.com/fastify/safe-regex2/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/fastify/safe-regex2/actions/workflows/ci.yml)\n[![NPM version](https://img.shields.io/npm/v/safe-regex2.svg?style=flat)](https://www.npmjs.com/package/safe-regex2)\n[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)\n\nDetect potentially [catastrophic](http://regular-expressions.mobi/catastrophic.html) [exponential-time](http://perlgeek.de/blog-en/perl-tips/in-search-of-an-exponetial-regexp.html)\nregular expressions by limiting the [star height](https://en.wikipedia.org/wiki/Star_height) to 1.\n\nThis is a fork of https://github.com/substack/safe-regex at 1.1.0.\n\nWARNING: This module has both false positives and false negatives.\nIt is not meant as a full checker, but it detects basic cases.\n\n## Install\n```sh\nnpm i safe-regex2\n```\n\n## Usage via npx\n\nYou can use this module via `npx` without installing it globally:\n\nExample:\n```sh\nnpx safe-regex2 '(x+x+)+y'\n```\n\n## Example\n\n``` js\nconst safe = require('safe-regex2');\nconst regex = process.argv.slice(2).join(' ');\nconsole.log(safe(regex));\n```\n\n```\n$ node safe.js '(x+x+)+y'\nfalse\n$ node safe.js '(beep|boop)*'\ntrue\n$ node safe.js '(a+){10}'\nfalse\n$ node safe.js '\\blocation\\s*:[^:\\n]+\\b(Oakland|San Francisco)\\b'\ntrue\n```\n\n## Methods\n\n``` js\nconst safe = require('safe-regex')\n```\n\n### const ok = safe(re, opts={})\n\nReturns a boolean indicating whether the regex `re` is safe\nand not possibly catastrophic.\n\n`re` can be a `RegExp` object or just a string.\n\nIf `re` is a string and is an invalid regex, it returns `false`.\n\n* `opts.limit` - maximum number of allowed repetitions in the entire regex.\nDefault: `25`.\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","publish_time":1776573359467,"_cnpm_publish_time":1776573359467,"dist-tags":{"latest":"5.1.2"}}