Function: normalizeBasePath()
API / @xmachines/play-url / index / normalizeBasePath
function normalizeBasePath(basePath?): string;Defined in: packages/play-url/src/base-path.ts:134
Normalizes a base path, and it substitutes no :param segment of that path.
Use this function when you want the form of the pattern, for example to declare the routes of a machine in a route config of a host that substitutes each param itself. resolveBasePath gives the form that a bridge needs.
Parameters
| Parameter | Type | Description |
|---|---|---|
basePath? | string | The prefix, as a pattern or as a concrete path. An absent value, "", and "/" all give "". |
Returns
string
The normalized prefix. It starts with /, and it carries no trailing /.
Throws
For a wildcard segment, for an optional :param?
segment, for a $param segment, for a query string or a hash fragment, for a URL
scheme, for a dot segment (., .., and their percent-encoded forms), and for any
segment that a browser rewrites — one that holds whitespace, a backslash, or a
character that a URL percent-encodes.
Example
normalizeBasePath("/:machineId/play/"); // "/:machineId/play"normalizeBasePath("admin"); // "/admin"normalizeBasePath("/"); // ""