switch case for URLs, a small tool for routing in JavaScript
npm install switch-pathswitchPath> Advanced switch case for URLs, a small tool for routing in JavaScript

```
npm install switch-path
Basic usage:
`js/home/foo
const {path, value} = switchPath('/home/foo', {
'/bar': 123,
'/home/foo': 456,
});
// path is `
// value is 456
Supports trailing slashes
`js/home/foo
const {path, value} = switchPath('/home/foo/', {
'/bar': 123,
'/home/foo': 456,
});
// path is `
// value is 456
Supports nested route configuration:
`js/home/foo
const {path, value} = switchPath('/home/foo', {
'/bar': 123,
'/home': {
'/foo': 456,
},
});
// path is `
// value is 456`
Supports base paths in nested route configurationsjs/home
const {path, value} = switchPath('/home', {
'/bar': 123,
'/home': {
'/': 456,
'/foo': 789
}
});
// path is `
// value is 456
Incomplete patterns will be optimistically matched:
`js/home
const {path, value} = switchPath('/home/foo', {
'/bar': 123,
'/home': 456,
});
// path is `
// value is 456
Optional not found pattern:
`js`
const {path, value} = switchPath('/home/33', {
'/': 123,
'books': {
'/': 456,
'/:id': 789
},
'*': 'Route not found'
});
// path = '/home/33'
// value = 'Route not found':param
Match a route with parameters and get the parameter value in a function:
`jsid is ${id}
const {path, value} = switchPath('/home/1736', {
'/bar': 123,
'/home/:id': id => ,/home/1736
});
// path is `
// value is 'id is 1736'
Match a route with :param parameters also inside nested configurations:
`jsid is ${id}
const {path, value} = switchPath('/home/1736', {
'/bar': 123,
'/home': {
'/:id': id => ,/home/1736
},
});
// path is `
// value is 'id is 1736'
Match a route with :param parameters base inside nested configurations:
`jsid is ${id}
const {path, value} = switchPath('/1736', {
'/bar': 123,
'/:id': {
'/': id => ,/1736
'/home': 789
}
});
// path is ``
// value is 'id is 1736'