const generatePath = (path, obj) =>
path.replace(/(:[a-z]+)/g, (v) => obj[v.substr(1)]);
const route = "/app/:page/:id";
generatePath(route, {
page: "products",
id: 85,
});
// /app/products/123
const generatePath = (path, obj) =>
path.replace(/(:[a-z]+)/g, (v) => obj[v.substr(1)]);
const route = "/app/:page/:id";
generatePath(route, {
page: "products",
id: 85,
});
// /app/products/123