A module to convert route template strings like
/my-route/:id
into valid url according to the params & query given. 🚀
$ npm install url-from-template
const buildUrl = require('url-from-template');
buildUrl('/test/:id', {params: {id: '123'}});
//=> '/test/123'
buildUrl('/test/:id', {params: {id: '123'}, query: {awesome: 'yeah'}});
//=> '/test/123?awesome=yeah'
Type: string
Template to generate url from. For params, you can use :
to make it a param.
When you give param to route, you must give its value in params object in options.
Type: Object
Type: Object
Params to replace in template.
Type: Object
Query params to add in route.
If your query has invalid value, it'll not be in the return url.
It uses the following awesome libraries:
MIT © with ❤️ & ☕ by Hamza Baig