Socket
Socket
Sign inDemoInstall

path-to-regexp

Package Overview
Dependencies
Maintainers
5
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 4.0.4 to 4.0.5

12

dist.es2015/index.js

@@ -10,12 +10,4 @@ /**

*/
export function normalizePathname(pathname, whitelist) {
if (whitelist === void 0) { whitelist = "%/-."; }
return pathname
.replace(/\/+/g, "/")
.replace(/(?:%[ef][0-9a-f](?:%[0-9a-f]{2}){2}|%[cd][0-9a-f]%[0-9a-f]{2}|%[0-9a-f]{2})/gi, function (m) {
var char = decodeURIComponent(m);
if (whitelist.indexOf(char) > -1)
return m;
return char;
});
export function normalizePathname(pathname) {
return decodeURI(pathname).replace(/\/+/g, "/");
}

@@ -22,0 +14,0 @@ /**

2

dist/index.d.ts

@@ -16,3 +16,3 @@ export interface ParseOptions {

*/
export declare function normalizePathname(pathname: string, whitelist?: string | string[]): string;
export declare function normalizePathname(pathname: string): string;
/**

@@ -19,0 +19,0 @@ * Parse a string for the raw tokens.

@@ -12,12 +12,4 @@ "use strict";

*/
function normalizePathname(pathname, whitelist) {
if (whitelist === void 0) { whitelist = "%/-."; }
return pathname
.replace(/\/+/g, "/")
.replace(/(?:%[ef][0-9a-f](?:%[0-9a-f]{2}){2}|%[cd][0-9a-f]%[0-9a-f]{2}|%[0-9a-f]{2})/gi, function (m) {
var char = decodeURIComponent(m);
if (whitelist.indexOf(char) > -1)
return m;
return char;
});
function normalizePathname(pathname) {
return decodeURI(pathname).replace(/\/+/g, "/");
}

@@ -24,0 +16,0 @@ exports.normalizePathname = normalizePathname;

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

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

@@ -21,9 +21,3 @@ # Path-to-RegExp

```javascript
const {
pathToRegexp,
match,
parse,
compile,
normalizePathname
} = require("path-to-regexp");
const { pathToRegexp, match, parse, compile } = require("path-to-regexp");

@@ -34,3 +28,2 @@ // pathToRegexp(path, keys?, options?)

// compile(path)
// normalizePathname(path)
```

@@ -176,7 +169,7 @@

The `normalizePathname` function will return a normalized string for matching with `pathToRegexp`.
The `normalizePathname` function will return a normalized string for matching with `pathToRegexp`:
```js
const re = pathToRegexp("/caf\u00E9");
const input = encodeURI("/cafe\u0301");
const input = encodeURI("/caf\u00E9");

@@ -187,2 +180,6 @@ re.test(input); //=> false

**Note:** It may be preferable to implement something in your own library that normalizes the pathname for matching. E.g. [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) automatically URI encodes paths for you, which would result in a consistent match.
**Tip:** Consider using [`String.prototype.normalize`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize) to resolve unicode variants of the same string.
### Parse

@@ -189,0 +186,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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc