Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

path-to-regexp

Package Overview
Dependencies
Maintainers
33
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.1.5 to 0.1.6

46

index.js

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

/**
* Match matching groups in a regular expression.
*/
var MATCHING_GROUP_REGEXP = /\((?!\?)/g;
/**
* Normalize the given path string,

@@ -26,2 +31,3 @@ * returning a regular expression.

options = options || {};
keys = keys || [];
var strict = options.strict;

@@ -31,6 +37,16 @@ var end = options.end !== false;

var extraOffset = 0;
var keysOffset = keys.length;
var i = 0;
var name = 0;
var m;
keys = keys || [];
if (path instanceof RegExp) {
while (m = MATCHING_GROUP_REGEXP.exec(path.source)) {
keys.push({
name: name++,
optional: false,
offset: m.index
});
}
if (path instanceof RegExp) {
return path;

@@ -62,4 +78,3 @@ }

optional: !!optional,
index: 0,
_offset: offset + extraOffset
offset: offset + extraOffset
});

@@ -82,4 +97,4 @@

while (len-- && keys[len]._offset > index) {
keys[len]._offset += 3;
while (len-- > keysOffset && keys[len].offset > index) {
keys[len].offset += 3;
}

@@ -90,12 +105,13 @@

// This is a workaround for handling *all* matching group positioning.
var re = /\((?!\?)/g;
var m;
// This is a workaround for handling unnamed matching groups.
while (m = MATCHING_GROUP_REGEXP.exec(path)) {
if (keysOffset + i === keys.length || keys[keysOffset + i].offset > m.index) {
keys.splice(keysOffset + i, 0, {
name: name++, // Unnamed matching groups must be consistently linear.
optional: false,
offset: m.index
});
}
while (m = re.exec(path)) {
var len = keys.length;
while (len-- && keys[len]._offset > m.index) {
keys[len].index++;
}
i++;
}

@@ -102,0 +118,0 @@

{
"name": "path-to-regexp",
"description": "Express style path to RegExp utility",
"version": "0.1.5",
"version": "0.1.6",
"files": [

@@ -6,0 +6,0 @@ "index.js",

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