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.4 to 0.2.5

2

component.json
{
"name": "path-to-regexp",
"description": "Express style path to RegExp utility",
"version": "0.2.3",
"version": "0.2.5",
"keywords": [

@@ -6,0 +6,0 @@ "express",

@@ -0,1 +1,13 @@

0.2.5 / 2014-08-07
==================
* Allow keys parameter to be omitted
0.2.4 / 2014-08-02
==================
* Code coverage badge
* Updated readme
* Attach keys to the generated regexp
0.2.3 / 2014-07-09

@@ -2,0 +14,0 @@ ==================

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

function pathtoRegexp (path, keys, options) {
if (keys && !Array.isArray(keys)) {
options = keys;
keys = null;
}
keys = keys || [];

@@ -63,0 +68,0 @@ options = options || {};

{
"name": "path-to-regexp",
"description": "Express style path to RegExp utility",
"version": "0.2.4",
"version": "0.2.5",
"scripts": {

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

@@ -843,33 +843,47 @@ var util = require('util');

describe('path-to-regexp', function () {
TESTS.forEach(function (test) {
var description = '';
var options = test[4] || {};
describe('arguments', function () {
it('should work without second keys', function () {
var re = pathToRegexp('/user/:id', { end: false });
var params = [
{ name: 'id', delimiter: '/', optional: false, repeat: false }
];
// Generate a base description using the test values.
description += 'should ' + (test[3] ? '' : 'not ') + 'match ';
description += util.inspect(test[2]) + ' against ' + util.inspect(test[0]);
assert.deepEqual(re.keys, params);
assert.deepEqual(exec(re, '/user/123/show'), ['/user/123', '123']);
});
});
// If additional options have been defined, we should render the options
// in the test descriptions.
if (Object.keys(options).length) {
var optionsDescription = Object.keys(options).map(function (key) {
return (options[key] === false ? 'non-' : '') + key;
}).join(', ');
describe('rules', function () {
TESTS.forEach(function (test) {
var description = '';
var options = test[4] || {};
description += ' in ' + optionsDescription + ' mode';
}
// Generate a base description using the test values.
description += 'should ' + (test[3] ? '' : 'not ') + 'match ';
description += util.inspect(test[2]) + ' against ' + util.inspect(test[0]);
// Execute the test and check each parameter is as expected.
it(description, function () {
var params = [];
var re = pathToRegexp(test[0], params, test[4]);
// If additional options have been defined, we should render the options
// in the test descriptions.
if (Object.keys(options).length) {
var optionsDescription = Object.keys(options).map(function (key) {
return (options[key] === false ? 'non-' : '') + key;
}).join(', ');
// Check the keys are as expected.
assert.equal(re.keys, params);
assert.deepEqual(params, test[1]);
description += ' in ' + optionsDescription + ' mode';
}
// Run the regexp and check the result is expected.
assert.deepEqual(exec(re, test[2]), test[3]);
// Execute the test and check each parameter is as expected.
it(description, function () {
var params = [];
var re = pathToRegexp(test[0], params, test[4]);
// Check the keys are as expected.
assert.equal(re.keys, params);
assert.deepEqual(params, test[1]);
// Run the regexp and check the result is expected.
assert.deepEqual(exec(re, test[2]), test[3]);
});
});
});
});
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