router-path
TypeScript icon, indicating that this package has built-in type declarations

2.2.1 • Public • Published

Utility function that replaces the params from a route template with the values of an object to create a valid route path. Designed for, but not limited to, React-router.

It supports both colons (:) and brackets ([]) as param delimiters.

Example with colons:

createPath('/foo/:bar', { bar: 'test' });

returns

'/foo/test'

Example with brackets:

createPath('user/[id]/[slug]', { id: 1, slug: 'john-do' });

returns

'user/1/john-do'

Readme

Keywords

Package Sidebar

Install

npm i router-path

Weekly Downloads

2

Version

2.2.1

License

ISC

Unpacked Size

14.2 kB

Total Files

15

Last publish

Collaborators

  • thi.js