A simple router based on bath.
$ npm install spa-town
import * as assert from 'assert';
import { result, route, router } from 'spa-town';
const router1 = router([
route('root#index', '/'),
route('users#index', '/users'),
route('users#index', '/users/'),
route('users#show', '/users/{id}', { id: /^\w+$/ }),
route('users#show', '/users/{id}/', { id: /^\w+$/ })
], result('root#notfound', {}));
assert.deepEqual(router1('/'), result('root#index', {}));
assert.deepEqual(router1('/users'), result('users#index', {}));
assert.deepEqual(router1('/users/'), result('users#index', {}));
assert.deepEqual(router1('/users/123'), result('users#show', { id: '123' }));
assert.deepEqual(router1('/users/123/'), result('users#show', { id: '123' }));
assert.deepEqual(router1('/no-match'), result('root#notfound', {}));