Skip to content

Utility to create router paths from a template and replaces the params. Design for, but not limited to, React-router

Notifications You must be signed in to change notification settings

ThijsTyZ/router-path

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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'

About

Utility to create router paths from a template and replaces the params. Design for, but not limited to, React-router

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published