diff options
Diffstat (limited to 'node_modules/to-regex')
-rw-r--r-- | node_modules/to-regex/LICENSE | 10 | ||||
-rw-r--r-- | node_modules/to-regex/README.md | 74 | ||||
-rw-r--r-- | node_modules/to-regex/index.js | 15 | ||||
-rw-r--r-- | node_modules/to-regex/package.json | 21 |
4 files changed, 74 insertions, 46 deletions
diff --git a/node_modules/to-regex/LICENSE b/node_modules/to-regex/LICENSE index 66ae69c71..7c9987bc6 100644 --- a/node_modules/to-regex/LICENSE +++ b/node_modules/to-regex/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016 Jon Schlinkert +Copyright (c) 2016-2018, Jon Schlinkert. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/to-regex/README.md b/node_modules/to-regex/README.md index decc6f87c..5a28fc33b 100644 --- a/node_modules/to-regex/README.md +++ b/node_modules/to-regex/README.md @@ -1,8 +1,8 @@ -# to-regex [](https://www.npmjs.com/package/to-regex) [](https://npmjs.org/package/to-regex) [](https://travis-ci.org/jonschlinkert/to-regex) +# to-regex [](https://www.npmjs.com/package/to-regex) [](https://npmjs.org/package/to-regex) [](https://npmjs.org/package/to-regex) [](https://travis-ci.org/jonschlinkert/to-regex) > Generate a regex from a string or array of strings. -## Table of Contents +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](#install) - [Usage](#usage) @@ -12,11 +12,9 @@ * [options.nocase](#optionsnocase) * [options.flags](#optionsflags) * [options.cache](#optionscache) + * [options.safe](#optionssafe) - [About](#about) * [Related projects](#related-projects) - * [Contributing](#contributing) - * [Building docs](#building-docs) - * [Running tests](#running-tests) * [Author](#author) * [License](#license) @@ -129,49 +127,79 @@ This also helps with debugging, since adding options and pattern are added to th toRegex('foo', {cache: false}); ``` -## About +### options.safe -### Related projects +**Type**: `Boolean` -* [has-glob](https://www.npmjs.com/package/has-glob): Returns `true` if an array has a glob pattern. | [homepage](https://github.com/jonschlinkert/has-glob "Returns `true` if an array has a glob pattern.") -* [is-glob](https://www.npmjs.com/package/is-glob): Returns `true` if the given string looks like a glob pattern or an extglob pattern… [more](https://github.com/jonschlinkert/is-glob) | [homepage](https://github.com/jonschlinkert/is-glob "Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a bet") -* [path-regex](https://www.npmjs.com/package/path-regex): Regular expression for matching the parts of a file path. | [homepage](https://github.com/regexps/path-regex "Regular expression for matching the parts of a file path.") -* [to-regex-range](https://www.npmjs.com/package/to-regex-range): Returns a regex-compatible range from two numbers, min and max, with 855,412 generated unit tests… [more](https://github.com/jonschlinkert/to-regex-range) | [homepage](https://github.com/jonschlinkert/to-regex-range "Returns a regex-compatible range from two numbers, min and max, with 855,412 generated unit tests to validate it's accuracy! Useful for creating regular expressions to validate numbers, ranges, years, etc. Returns a string, allowing the returned value to ") +**Default**: `undefined` -### Contributing +Check the generated regular expression with [safe-regex](https://github.com/substack/safe-regex) and throw an error if the regex is potentially unsafe. + +**Examples** + +```js +console.log(toRegex('(x+x+)+y')); +//=> /^(?:(x+x+)+y)$/ + +// The following would throw an error +toRegex('(x+x+)+y', {safe: true}); +``` + +## About + +<details> +<summary><strong>Contributing</strong></summary> 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> + +<details> +<summary><strong>Building docs</strong></summary> -Install dev dependencies: +_(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: + +* [has-glob](https://www.npmjs.com/package/has-glob): Returns `true` if an array has a glob pattern. | [homepage](https://github.com/jonschlinkert/has-glob "Returns `true` if an array has a glob pattern.") +* [is-glob](https://www.npmjs.com/package/is-glob): Returns `true` if the given string looks like a glob pattern or an extglob pattern… [more](https://github.com/jonschlinkert/is-glob) | [homepage](https://github.com/jonschlinkert/is-glob "Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a bet") +* [path-regex](https://www.npmjs.com/package/path-regex): Regular expression for matching the parts of a file path. | [homepage](https://github.com/regexps/path-regex "Regular expression for matching the parts of a file path.") +* [to-regex-range](https://www.npmjs.com/package/to-regex-range): Pass two numbers, get a regex-compatible source string for matching ranges. Validated against more than… [more](https://github.com/micromatch/to-regex-range) | [homepage](https://github.com/micromatch/to-regex-range "Pass two numbers, get a regex-compatible source string for matching ranges. Validated against more than 2.78 million test assertions.") + ### Author **Jon Schlinkert** +* [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/to-regex/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 16, 2016._
\ No newline at end of file +_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on February 24, 2018._
\ No newline at end of file diff --git a/node_modules/to-regex/index.js b/node_modules/to-regex/index.js index 9c93def8c..a87d01591 100644 --- a/node_modules/to-regex/index.js +++ b/node_modules/to-regex/index.js @@ -1,5 +1,6 @@ 'use strict'; +var safe = require('safe-regex'); var define = require('define-property'); var extend = require('extend-shallow'); var not = require('regex-not'); @@ -86,10 +87,16 @@ function makeRe(pattern, options) { if (opts.negate || typeof opts.strictNegate === 'boolean') { pattern = not.create(pattern, opts); } + var str = open + '(?:' + pattern + ')' + close; regex = new RegExp(str, flags); + + if (opts.safe === true && safe(regex) === false) { + throw new Error('potentially unsafe regular expression: ' + regex.source); + } + } catch (err) { - if (opts.strictErrors === true) { + if (opts.strictErrors === true || opts.safe === true) { err.key = key; err.pattern = pattern; err.originalOptions = options; @@ -105,18 +112,18 @@ function makeRe(pattern, options) { } if (opts.cache !== false) { - cacheRegex(regex, key, pattern, opts); + memoize(regex, key, pattern, opts); } return regex; } /** - * Cache generated regex. This can result in dramatic speed improvements + * Memoize generated regex. This can result in dramatic speed improvements * and simplify debugging by adding options and pattern to the regex. It can be * disabled by passing setting `options.cache` to false. */ -function cacheRegex(regex, key, pattern, options) { +function memoize(regex, key, pattern, options) { define(regex, 'cached', true); define(regex, 'pattern', pattern); define(regex, 'options', options); diff --git a/node_modules/to-regex/package.json b/node_modules/to-regex/package.json index 2ccd04539..e4277d316 100644 --- a/node_modules/to-regex/package.json +++ b/node_modules/to-regex/package.json @@ -1,7 +1,7 @@ { "name": "to-regex", "description": "Generate a regex from a string or array of strings.", - "version": "3.0.1", + "version": "3.0.2", "homepage": "https://github.com/jonschlinkert/to-regex", "author": "Jon Schlinkert (https://github.com/jonschlinkert)", "repository": "jonschlinkert/to-regex", @@ -20,17 +20,14 @@ "test": "mocha" }, "dependencies": { - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "regex-not": "^1.0.0" + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "regex-not": "^1.0.2", + "safe-regex": "^1.1.0" }, "devDependencies": { - "gulp": "^3.9.1", - "gulp-eslint": "^3.0.1", - "gulp-format-md": "^0.1.10", - "gulp-istanbul": "^1.1.1", - "gulp-mocha": "^3.0.1", - "mocha": "^3.0.2" + "gulp-format-md": "^1.0.0", + "mocha": "^3.5.3" }, "keywords": [ "match", @@ -58,10 +55,6 @@ "to-regex-range" ] }, - "reflinks": [ - "verb", - "verb-generate-readme" - ], "lint": { "reflinks": true } |