Skip to content

Commit

Permalink
docs(readme): use .md extension, add badges
Browse files Browse the repository at this point in the history
Signed-off-by: Frazer Smith <[email protected]>
  • Loading branch information
Fdawgs authored Dec 30, 2024
1 parent d208c51 commit fd19de1
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions readme.markdown → README.md
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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.
Expand All @@ -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).

0 comments on commit fd19de1

Please sign in to comment.