UrlPattern
Sourceimport { UrlPattern } from "@prestojs/routing";
Allows definition of URL as a pattern with ability to resolve it to a URL by performing argument replacement
Patterns are defined using the path-to-regexp library
Usage:
const url = new UrlPattern('/users/:id/'),url.resolve({ id: 5 });// /users/5/url.resolve({ id: 5 }, { query: { showAddresses: true }});// /users/5/?showAddresses=true
API
Constructor
new UrlPattern(pattern)
SourceParameter | Type | Description | |
---|---|---|---|
* | pattern | string |