Socket
Socket
Sign inDemoInstall

path-to-regexp

Package Overview
Dependencies
Maintainers
29
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

path-to-regexp - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

24

index.js

@@ -6,2 +6,7 @@ /**

/**
* The main path matching regexp utility.
*
* @type {RegExp}
*/
var PATH_REGEXP = new RegExp([

@@ -33,2 +38,15 @@ // Match already escaped characters that would otherwise incorrectly appear

/**
* Attach the keys as a property of the regexp.
*
* @param {RegExp} re
* @param {Array} keys
* @return {RegExp}
*/
var attachKeys = function (re, keys) {
re.keys = keys;
return re;
};
/**
* Normalize the given path string, returning a regular expression.

@@ -68,3 +86,3 @@ *

// Return the source back to the user.
return path;
return attachKeys(path, keys);
}

@@ -81,3 +99,3 @@

// Generate a new regexp instance by joining all the parts together.
return new RegExp('(?:' + path.join('|') + ')', flags);
return attachKeys(new RegExp('(?:' + path.join('|') + ')', flags), keys);
}

@@ -147,3 +165,3 @@

return new RegExp('^' + path + (end ? '$' : ''), flags);
return attachKeys(new RegExp('^' + path + (end ? '$' : ''), flags), keys);
};

2

package.json
{
"name": "path-to-regexp",
"description": "Express style path to RegExp utility",
"version": "0.2.3",
"version": "0.2.4",
"scripts": {

@@ -6,0 +6,0 @@ "test": "istanbul cover node_modules/mocha/bin/_mocha -- -R spec"

@@ -5,5 +5,12 @@ # Path-to-RegExp

[![Build Status](https://img.shields.io/travis/component/path-to-regexp/master.svg)](https://travis-ci.org/component/path-to-regexp)
[![NPM version](https://img.shields.io/npm/v/path-to-regexp.svg)](https://www.npmjs.org/package/path-to-regexp)
[![NPM version][npm-image]][npm-url]
[![Build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
## Installation
```
npm install path-to-regexp --save
```
## Usage

@@ -123,3 +130,3 @@

Path-To-RegExp breaks compatibility with Express 3.x in a few ways:
Path-To-RegExp breaks compatibility with Express <= 4.x in a few ways:

@@ -130,2 +137,3 @@ * RegExp special characters can now be used in the regular path. E.g. `/user[(\\d+)]`

* Parameters can have suffixes that augment meaning - `*`, `+` and `?`. E.g. `/:user*`
* Strings aren't interpreted as literal regexp strings - no more non-capturing groups, lookaheads, lookbehinds or nested matching groups (but you can still pass a regexp manually)

@@ -139,1 +147,8 @@ ## Live Demo

MIT
[npm-image]: https://img.shields.io/npm/v/path-to-regexp.svg?style=flat
[npm-url]: https://npmjs.org/package/path-to-regexp
[travis-image]: https://img.shields.io/travis/component/path-to-regexp.svg?style=flat
[travis-url]: https://travis-ci.org/component/path-to-regexp
[coveralls-image]: https://img.shields.io/coveralls/component/path-to-regexp.svg?style=flat
[coveralls-url]: https://coveralls.io/r/component/path-to-regexp?branch=master

@@ -817,5 +817,14 @@ var util = require('util');

/**
* Regressions.
* Real world examples.
*/
[
'/:foo/:bar',
[
{ name: 'foo', delimiter: '/', optional: false, repeat: false },
{ name: 'bar', delimiter: '/', optional: false, repeat: false }
],
'/match/route',
['/match/route', 'match', 'route']
],
[
'/:remote([\\w-.]+)/:user([\\w-]+)',

@@ -835,8 +844,2 @@ [

describe('path-to-regexp', function () {
it('should not break when keys aren\'t provided', function () {
var re = pathToRegexp('/:foo/:bar');
assert.deepEqual(exec(re, '/test/route'), ['/test/route', 'test', 'route']);
});
TESTS.forEach(function (test) {

@@ -865,3 +868,4 @@ var description = '';

// Check the params are as expected.
// Check the keys are as expected.
assert.equal(re.keys, params);
assert.deepEqual(params, test[1]);

@@ -868,0 +872,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc