Skip to main content
Module

x/urlcat/src/index.ts>subst

A URL builder library for JavaScript.
Go to Latest
function subst
import { subst } from "https://deno.land/x/urlcat@v2.0.4/src/index.ts";

Substitutes :params in a template with property values of an object.

Examples

Example 1

subst('/users/:id/posts/:postId', { id: 42, postId: 36 })
// -> '/users/42/posts/36'

Parameters

template: string

a string that contains :params.

params: ParamMap

an object with keys that correspond to the params in the template.

Returns

string

Rendered path after substitution.