/** * Fill a given path with parameters by replacing the placeholder * @param path e.g. /user/{id}/edit * @param params key-value pair */ export const fillPath = (path: string, params: Record): string => { for (const key of Object.keys(params)) { path = path.replace(new RegExp(`{${key}}`, "g"), params[key]); } return path; };