From fd19de10a473801959e04349bc68fb619c9c6527 Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Mon, 30 Dec 2024 13:24:06 +0000 Subject: [PATCH] docs(readme): use `.md` extension, add badges Signed-off-by: Frazer Smith --- readme.markdown => README.md | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) rename readme.markdown => README.md (62%) diff --git a/readme.markdown b/README.md similarity index 62% rename from readme.markdown rename to README.md index 2d9ebcc..bd93505 100644 --- a/readme.markdown +++ b/README.md @@ -1,17 +1,26 @@ # safe-regex2 -detect potentially +[![CI](https://github.com/fastify/safe-regex2/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/fastify/safe-regex2/actions/workflows/ci.yml) +[![NPM version](https://img.shields.io/npm/v/safe-regex2.svg?style=flat)](https://www.npmjs.com/package/safe-regex2) +[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard) + +Detect potentially [catastrophic](http://regular-expressions.mobi/catastrophic.html) [exponential-time](http://perlgeek.de/blog-en/perl-tips/in-search-of-an-exponetial-regexp.html) regular expressions by limiting the -[star height](https://en.wikipedia.org/wiki/Star_height) to 1 +[star height](https://en.wikipedia.org/wiki/Star_height) to 1. This is a fork of https://github.com/substack/safe-regex at 1.1.0. WARNING: This module has both false positives and false negatives. It is not meant as a full checker, but it detect basic cases. -# example +## Install +``` +npm i safe-regex2 +``` + +## Example ``` js const safe = require('safe-regex2'); @@ -30,13 +39,13 @@ $ node safe.js '\blocation\s*:[^:\n]+\b(Oakland|San Francisco)\b' true ``` -# methods +## Methods ``` js const safe = require('safe-regex') ``` -## const ok = safe(re, opts={}) +### const ok = safe(re, opts={}) Return a boolean `ok` whether or not the regex `re` is safe and not possibly catastrophic. @@ -48,14 +57,6 @@ If the `re` is a string and is an invalid regex, returns `false`. * `opts.limit` - maximum number of allowed repetitions in the entire regex. Default: `25`. -# install - -With [npm](https://npmjs.org) do: - -``` -npm install safe-regex2 -``` - -# license +## License -MIT +Licensed under [MIT](./LICENSE).