path-to-regexp
Advanced tools
Comparing version 6.2.1 to 6.2.2
@@ -33,3 +33,3 @@ export interface ParseOptions { | ||
export declare function compile<P extends object = object>(str: string, options?: ParseOptions & TokensToFunctionOptions): PathFunction<P>; | ||
export declare type PathFunction<P extends object = object> = (data?: P) => string; | ||
export type PathFunction<P extends object = object> = (data?: P) => string; | ||
/** | ||
@@ -56,7 +56,7 @@ * Expose a method for transforming tokens into the path function. | ||
*/ | ||
export declare type Match<P extends object = object> = false | MatchResult<P>; | ||
export type Match<P extends object = object> = false | MatchResult<P>; | ||
/** | ||
* The match function takes a string and returns whether it matched the path. | ||
*/ | ||
export declare type MatchFunction<P extends object = object> = (path: string) => Match<P>; | ||
export type MatchFunction<P extends object = object> = (path: string) => Match<P>; | ||
/** | ||
@@ -83,3 +83,3 @@ * Create path match function from `path-to-regexp` spec. | ||
*/ | ||
export declare type Token = string | Key; | ||
export type Token = string | Key; | ||
export interface TokensToRegexpOptions { | ||
@@ -122,3 +122,3 @@ /** | ||
*/ | ||
export declare type Path = string | RegExp | Array<string | RegExp>; | ||
export type Path = string | RegExp | Array<string | RegExp>; | ||
/** | ||
@@ -125,0 +125,0 @@ * Normalize the given path string, returning a regular expression. |
{ | ||
"name": "path-to-regexp", | ||
"version": "6.2.1", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"version": "6.2.2", | ||
"description": "Express style path to RegExp utility", | ||
"license": "MIT", | ||
"keywords": [ | ||
"express", | ||
"regexp", | ||
"route", | ||
"routing" | ||
], | ||
"repository": { | ||
@@ -13,4 +15,11 @@ "type": "git", | ||
}, | ||
"license": "MIT", | ||
"sideEffects": false, | ||
"main": "dist/index.js", | ||
"module": "dist.es2015/index.js", | ||
"typings": "dist/index.d.ts", | ||
"files": [ | ||
"dist.es2015/", | ||
"dist/" | ||
], | ||
"scripts": { | ||
@@ -25,28 +34,19 @@ "build": "ts-scripts build", | ||
}, | ||
"files": [ | ||
"dist.es2015/", | ||
"dist/" | ||
], | ||
"keywords": [ | ||
"express", | ||
"regexp", | ||
"route", | ||
"routing" | ||
], | ||
"devDependencies": { | ||
"@borderless/ts-scripts": "^0.8.0", | ||
"@size-limit/preset-small-lib": "^7.0.8", | ||
"@types/jest": "^27.4.0", | ||
"@types/node": "^17.0.17", | ||
"@borderless/ts-scripts": "^0.15.0", | ||
"@size-limit/preset-small-lib": "^11.1.2", | ||
"@types/node": "^20.4.9", | ||
"@types/semver": "^7.3.1", | ||
"@vitest/coverage-v8": "^1.4.0", | ||
"semver": "^7.3.5", | ||
"size-limit": "^7.0.8", | ||
"typescript": "^4.5.5" | ||
"size-limit": "^11.1.2", | ||
"typescript": "^5.1.6" | ||
}, | ||
"typings": "dist/index.d.ts", | ||
"sideEffects": false, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"size-limit": [ | ||
{ | ||
"path": "dist.es2015/index.js", | ||
"limit": "2.1 kB" | ||
"limit": "2 kB" | ||
} | ||
@@ -53,0 +53,0 @@ ], |
@@ -287,11 +287,10 @@ # Path-to-RegExp | ||
toPath({ id: "café" }); //=> "/user/caf%C3%A9" | ||
toPath({ id: "/" }); //=> "/user/%2F" | ||
toPath({ id: ":/" }); //=> "/user/%3A%2F" | ||
// Without `encode`, you need to make sure inputs are encoded correctly. | ||
const toPathRaw = compile("/user/:id"); | ||
// (Note: You can use `validate: false` to create an invalid paths.) | ||
const toPathRaw = compile("/user/:id", { validate: false }); | ||
toPathRaw({ id: "%3A%2F" }); //=> "/user/%3A%2F" | ||
toPathRaw({ id: ":/" }, { validate: false }); //=> "/user/:/" | ||
toPathRaw({ id: ":/" }); //=> "/user/:/" | ||
@@ -307,4 +306,2 @@ const toPathRepeated = compile("/:segment+"); | ||
toPathRegexp({ id: "123" }); //=> "/user/123" | ||
toPathRegexp({ id: "abc" }); //=> Throws `TypeError`. | ||
toPathRegexp({ id: "abc" }, { validate: false }); //=> "/user/abc" | ||
``` | ||
@@ -350,3 +347,3 @@ | ||
[downloads-url]: https://npmjs.org/package/path-to-regexp | ||
[build-image]: https://img.shields.io/github/workflow/status/pillarjs/path-to-regexp/CI/master | ||
[build-image]: https://img.shields.io/github/actions/workflow/status/pillarjs/path-to-regexp/ci.yml?branch=master | ||
[build-url]: https://github.com/pillarjs/path-to-regexp/actions/workflows/ci.yml?query=branch%3Amaster | ||
@@ -353,0 +350,0 @@ [coverage-image]: https://img.shields.io/codecov/c/gh/pillarjs/path-to-regexp |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
107717
351