Basic repeatable code:
const routes = {
'/:id': {
"/": id => `${id}`,
"/profile": id => `${id} profile`
}
}
const {path, value} = switchPath('/1/profile', routes)
/* actual
path === '/1/profile'
value === '1'
*/
/* expected
path === '/1/profile'
value === '1 profile'
*/