Skip to main content

path

Create a route path pattern.

Parameters

path is not called with traditional parameters, but with tagged template literals. The "substitutions" in the literal can be either Param objects, or strings, which get automatically converted into parameters via normalizeParam.

Return value

A PathPattern object.

Usage

import { path } from "@snout/router-path";

const user = path`/user/${"id"}`;

user.match("/user/111"); // returns { id: "111" }
user.build({ id: "111" }); // returns "/user/111"