Socket
Socket
Sign inDemoInstall

path-to-regexp

Package Overview
Dependencies
0
Maintainers
5
Versions
55
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.0.0 to 6.1.0

6

dist.es2015/index.js

@@ -97,3 +97,3 @@ /**

var _a = options.prefixes, prefixes = _a === void 0 ? "./" : _a;
var defaultPattern = "[^" + escapeString(options.delimiter || "/") + "]+?";
var defaultPattern = "[^" + escapeString(options.delimiter || "/#?") + "]+?";
var result = [];

@@ -332,3 +332,3 @@ var key = 0;

var endsWith = "[" + escapeString(options.endsWith || "") + "]|$";
var delimiter = "[" + escapeString(options.delimiter || "/") + "]";
var delimiter = "[" + escapeString(options.delimiter || "/#?") + "]";
var route = start ? "^" : "";

@@ -368,3 +368,3 @@ // Iterate over the tokens and create our regexp string.

route += delimiter + "?";
route += endsWith === "$" ? "$" : "(?=" + endsWith + ")";
route += !options.endsWith ? "$" : "(?=" + endsWith + ")";
}

@@ -371,0 +371,0 @@ else {

@@ -99,3 +99,3 @@ "use strict";

var _a = options.prefixes, prefixes = _a === void 0 ? "./" : _a;
var defaultPattern = "[^" + escapeString(options.delimiter || "/") + "]+?";
var defaultPattern = "[^" + escapeString(options.delimiter || "/#?") + "]+?";
var result = [];

@@ -339,3 +339,3 @@ var key = 0;

var endsWith = "[" + escapeString(options.endsWith || "") + "]|$";
var delimiter = "[" + escapeString(options.delimiter || "/") + "]";
var delimiter = "[" + escapeString(options.delimiter || "/#?") + "]";
var route = start ? "^" : "";

@@ -375,3 +375,3 @@ // Iterate over the tokens and create our regexp string.

route += delimiter + "?";
route += endsWith === "$" ? "$" : "(?=" + endsWith + ")";
route += !options.endsWith ? "$" : "(?=" + endsWith + ")";
}

@@ -378,0 +378,0 @@ else {

{
"name": "path-to-regexp",
"description": "Express style path to RegExp utility",
"version": "6.0.0",
"version": "6.1.0",
"main": "dist/index.js",

@@ -6,0 +6,0 @@ "typings": "dist/index.d.ts",

@@ -36,3 +36,3 @@ # Path-to-RegExp

- **start** When `true` the regexp will match from the beginning of the string. (default: `true`)
- **delimiter** The default delimiter for segments, e.g. `[^/]` for `:named` patterns. (default: `'/'`)
- **delimiter** The default delimiter for segments, e.g. `[^/#?]` for `:named` patterns. (default: `'/#?'`)
- **endsWith** Optional character, or list of characters, to treat as "end" characters.

@@ -46,6 +46,6 @@ - **encode** A function to encode strings before inserting into `RegExp`. (default: `x => x`)

// regexp = /^\/foo\/([^\/]+?)\/?$/i
// keys = [{ name: 'bar', prefix: '/', delimiter: '/', optional: false, repeat: false, pattern: '[^\\/]+?' }]
// keys = [{ name: 'bar', prefix: '/', suffix: '', pattern: '[^\\/#\\?]+?', modifier: '' }]
```
**Please note:** The `RegExp` returned by `path-to-regexp` is intended for ordered data (e.g. pathnames, hostnames). It can not handle arbitrarily ordered data (e.g. query strings, URL fragments, JSON, etc).
**Please note:** The `RegExp` returned by `path-to-regexp` is intended for ordered data (e.g. pathnames, hostnames). It can not handle arbitrarily ordered data (e.g. query strings, URL fragments, JSON, etc). When using paths that contain query strings, you need to escape the question mark (`?`) to ensure it does not flag the parameter as [optional](#optional).

@@ -132,3 +132,3 @@ ### Parameters

const regexp = pathToRegexp("/:foo/:bar?");
// keys = [{ name: 'foo', ... }, { name: 'bar', delimiter: '/', optional: true, repeat: false }]
// keys = [{ name: 'foo', ... }, { name: 'bar', prefix: '/', modifier: '?' }]

@@ -144,2 +144,15 @@ regexp.exec("/test");

When dealing with query strings, escape the question mark (`?`) so it doesn't mark the parameter as optional. Handling unordered data is outside the scope of this library.
```js
const regexp = pathToRegexp("/search/:tableName\\?useIndex=true&term=amazing");
regexp.exec("/search/people?useIndex=true&term=amazing");
//=> [ '/search/people?useIndex=true&term=amazing', 'people', index: 0, input: '/search/people?useIndex=true&term=amazing', groups: undefined ]
// This library does not handle query strings in different orders
regexp.exec("/search/people?term=amazing&useIndex=true");
//=> null
```
##### Zero or more

@@ -151,3 +164,3 @@

const regexp = pathToRegexp("/:foo*");
// keys = [{ name: 'foo', delimiter: '/', optional: true, repeat: true }]
// keys = [{ name: 'foo', prefix: '/', modifier: '*' }]

@@ -167,3 +180,3 @@ regexp.exec("/");

const regexp = pathToRegexp("/:foo+");
// keys = [{ name: 'foo', delimiter: '/', optional: false, repeat: true }]
// keys = [{ name: 'foo', prefix: '/', modifier: '+' }]

@@ -242,6 +255,6 @@ regexp.exec("/");

console.log(tokens[1]);
//=> { name: 'foo', prefix: '/', delimiter: '/', optional: false, repeat: false, pattern: '[^\\/]+?' }
//=> { name: 'foo', prefix: '/', suffix: '', pattern: '[^\\/#\\?]+?', modifier: '' }
console.log(tokens[2]);
//=> { name: 0, prefix: '/', delimiter: '/', optional: false, repeat: false, pattern: '.*' }
//=> { name: 0, prefix: '/', suffix: '', pattern: '.*', modifier: '' }
```

@@ -248,0 +261,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc