Comparing version 1.0.0 to 1.0.1
12
index.js
'use strict'; | ||
var extend = require('extend-shallow'); | ||
var safe = require('safe-regex'); | ||
@@ -44,3 +45,3 @@ /** | ||
var opts = extend({}, options); | ||
if (opts && opts.contains === true) { | ||
if (opts.contains === true) { | ||
opts.strictNegate = false; | ||
@@ -54,3 +55,3 @@ } | ||
if (opts && opts.strictNegate === false) { | ||
if (opts.strictNegate === false) { | ||
str = '(?:(?!(?:' + pattern + ')).)' + endChar; | ||
@@ -61,3 +62,8 @@ } else { | ||
return open + str + close; | ||
var res = open + str + close; | ||
if (opts.safe !== false && safe(res) === false) { | ||
throw new Error('potentially unsafe regular expression: ' + res); | ||
} | ||
return res; | ||
}; | ||
@@ -64,0 +70,0 @@ |
{ | ||
"name": "regex-not", | ||
"description": "Create a javascript regular expression for matching everything except for the given string.", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"homepage": "https://github.com/jonschlinkert/regex-not", | ||
@@ -23,7 +23,8 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"dependencies": { | ||
"extend-shallow": "^2.0.1" | ||
"extend-shallow": "^3.0.2", | ||
"safe-regex": "^1.1.0" | ||
}, | ||
"devDependencies": { | ||
"gulp-format-md": "^0.1.10", | ||
"mocha": "^3.0.2" | ||
"gulp-format-md": "^1.0.0", | ||
"mocha": "^3.5.3" | ||
}, | ||
@@ -30,0 +31,0 @@ "keywords": [ |
@@ -1,5 +0,7 @@ | ||
# regex-not [![NPM version](https://img.shields.io/npm/v/regex-not.svg?style=flat)](https://www.npmjs.com/package/regex-not) [![NPM downloads](https://img.shields.io/npm/dm/regex-not.svg?style=flat)](https://npmjs.org/package/regex-not) [![Build Status](https://img.shields.io/travis/jonschlinkert/regex-not.svg?style=flat)](https://travis-ci.org/jonschlinkert/regex-not) | ||
# regex-not [![NPM version](https://img.shields.io/npm/v/regex-not.svg?style=flat)](https://www.npmjs.com/package/regex-not) [![NPM monthly downloads](https://img.shields.io/npm/dm/regex-not.svg?style=flat)](https://npmjs.org/package/regex-not) [![NPM total downloads](https://img.shields.io/npm/dt/regex-not.svg?style=flat)](https://npmjs.org/package/regex-not) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/regex-not.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/regex-not) | ||
> Create a javascript regular expression for matching everything except for the given string. | ||
Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support. | ||
## Install | ||
@@ -30,3 +32,3 @@ | ||
console.log(not('foo')); | ||
//=> /^(?:(?!^(?:foo)$).)*$/ | ||
//=> /^(?:(?!^(?:foo)$).)+$/ | ||
``` | ||
@@ -52,3 +54,3 @@ | ||
console.log(not.create('foo')); | ||
//=> '(?:(?!^(?:foo)$).)*' | ||
//=> '(?:(?!^(?:foo)$).)+' | ||
``` | ||
@@ -72,29 +74,48 @@ | ||
### Related projects | ||
<details> | ||
<summary><strong>Contributing</strong></summary> | ||
* [regex-cache](https://www.npmjs.com/package/regex-cache): Memoize the results of a call to the RegExp constructor, avoiding repetitious runtime compilation of… [more](https://github.com/jonschlinkert/regex-cache) | [homepage](https://github.com/jonschlinkert/regex-cache "Memoize the results of a call to the RegExp constructor, avoiding repetitious runtime compilation of the same string and options, resulting in suprising performance improvements.") | ||
* [to-regex](https://www.npmjs.com/package/to-regex): Generate a regex from a string or array of strings. | [homepage](https://github.com/jonschlinkert/to-regex "Generate a regex from a string or array of strings.") | ||
### Contributing | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). | ||
### Building docs | ||
</details> | ||
_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_ | ||
<details> | ||
<summary><strong>Running Tests</strong></summary> | ||
To generate the readme and API documentation with [verb](https://github.com/verbose/verb): | ||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: | ||
```sh | ||
$ npm install -g verb verb-generate-readme && verb | ||
$ npm install && npm test | ||
``` | ||
### Running tests | ||
</details> | ||
Install dev dependencies: | ||
<details> | ||
<summary><strong>Building docs</strong></summary> | ||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ | ||
To generate the readme, run the following command: | ||
```sh | ||
$ npm install -d && npm test | ||
$ npm install -g verbose/verb#dev verb-generate-readme && verb | ||
``` | ||
</details> | ||
### Related projects | ||
You might also be interested in these projects: | ||
* [regex-cache](https://www.npmjs.com/package/regex-cache): Memoize the results of a call to the RegExp constructor, avoiding repetitious runtime compilation of… [more](https://github.com/jonschlinkert/regex-cache) | [homepage](https://github.com/jonschlinkert/regex-cache "Memoize the results of a call to the RegExp constructor, avoiding repetitious runtime compilation of the same string and options, resulting in surprising performance improvements.") | ||
* [to-regex](https://www.npmjs.com/package/to-regex): Generate a regex from a string or array of strings. | [homepage](https://github.com/jonschlinkert/to-regex "Generate a regex from a string or array of strings.") | ||
### Contributors | ||
| **Commits** | **Contributor** | | ||
| --- | --- | | ||
| 9 | [jonschlinkert](https://github.com/jonschlinkert) | | ||
| 1 | [doowb](https://github.com/doowb) | | ||
| 1 | [EdwardBetts](https://github.com/EdwardBetts) | | ||
### Author | ||
@@ -104,12 +125,13 @@ | ||
* [linkedin/in/jonschlinkert](https://linkedin.com/in/jonschlinkert) | ||
* [github/jonschlinkert](https://github.com/jonschlinkert) | ||
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert) | ||
### License | ||
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert). | ||
Released under the [MIT license](https://github.com/jonschlinkert/regex-not/blob/master/LICENSE). | ||
Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert). | ||
Released under the [MIT License](LICENSE). | ||
*** | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.31, on October 07, 2016._ | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on February 19, 2018._ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8460
60
133
2
+ Addedsafe-regex@^1.1.0
+ Addedassign-symbols@1.0.0(transitive)
+ Addedextend-shallow@3.0.2(transitive)
+ Addedis-extendable@1.0.1(transitive)
+ Addedis-plain-object@2.0.4(transitive)
+ Addedisobject@3.0.1(transitive)
+ Addedret@0.1.15(transitive)
+ Addedsafe-regex@1.1.0(transitive)
- Removedextend-shallow@2.0.1(transitive)
- Removedis-extendable@0.1.1(transitive)
Updatedextend-shallow@^3.0.2