{"id":14969159,"url":"https://github.com/fastify/safe-regex2","last_synced_at":"2025-10-19T09:32:23.683Z","repository":{"id":34184566,"uuid":"171219776","full_name":"fastify/safe-regex2","owner":"fastify","description":"detect possibly catastrophic, exponential-time regular expressions","archived":false,"fork":false,"pushed_at":"2024-07-12T12:12:17.000Z","size":49,"stargazers_count":35,"open_issues_count":1,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-09-28T11:20:59.093Z","etag":null,"topics":["fastify-fork","fastify-library"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"inno-v/safe-regex","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fastify.png","metadata":{"files":{"readme":"readme.markdown","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"fastify","open_collective":"fastify"}},"created_at":"2019-02-18T05:22:22.000Z","updated_at":"2024-08-22T20:08:28.000Z","dependencies_parsed_at":"2023-01-16T22:45:41.202Z","dependency_job_id":"8b9be49a-45b9-496f-b2e9-2aff387adff7","html_url":"https://github.com/fastify/safe-regex2","commit_stats":{"total_commits":58,"total_committers":11,"mean_commits":"5.2727272727272725","dds":0.7068965517241379,"last_synced_commit":"90e7177a45e993203898398c77b2f087d1dc23d8"},"previous_names":["fastify/safe-regex"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Fsafe-regex2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Fsafe-regex2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Fsafe-regex2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Fsafe-regex2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fastify","download_url":"https://codeload.github.com/fastify/safe-regex2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219869246,"owners_count":16555572,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fastify-fork","fastify-library"],"created_at":"2024-09-24T13:41:15.044Z","updated_at":"2025-10-19T09:32:23.365Z","avatar_url":"https://github.com/fastify.png","language":"JavaScript","readme":"# safe-regex2\n\ndetect potentially\n[catastrophic](http://regular-expressions.mobi/catastrophic.html)\n[exponential-time](http://perlgeek.de/blog-en/perl-tips/in-search-of-an-exponetial-regexp.html)\nregular expressions by limiting the\n[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 detect basic cases.\n\n# example\n\n``` js\nvar safe = require('safe-regex2');\nvar 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\nvar safe = require('safe-regex')\n```\n\n## var ok = safe(re, opts={})\n\nReturn a boolean `ok` whether or not the regex `re` is safe and not possibly\ncatastrophic.\n\n`re` can be a `RegExp` object or just a string.\n\nIf the `re` is a string and is an invalid regex, returns `false`.\n\n* `opts.limit` - maximum number of allowed repetitions in the entire regex.\nDefault: `25`.\n\n# install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install safe-regex2\n```\n\n# license\n\nMIT\n","funding_links":["https://github.com/sponsors/fastify","https://opencollective.com/fastify"],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastify%2Fsafe-regex2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffastify%2Fsafe-regex2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastify%2Fsafe-regex2/lists"}