Releases: kriasoft/universal-router
Releases · kriasoft/universal-router
7.0.0 - 2018-10-11
- The router no longer mutate errors to avoid issues with non-extensible objects. (BREAKING CHANGE #158).
Migration from v6 to v7:
- If your code relies on
error.context
orerror.code
you still can access them usingerrorHandler
option:errorHandler(error, context) { const code = error.status || 500 console.log(error, context, code) }
6.0.0 - 2018-02-06
5.1.0 - 2018-01-16
- Allow any string to be a valid route name (#145)
5.0.0 - 2017-10-30
- Skip nested routes when a middleware route returns
null
(BREAKING CHANGE #140)
Migration from v4 to v5:
- If you are using
resolveRoute
option for custom route handling logic then you need to returnundefined
instead ofnull
in cases when a route should not match - Make sure that your middleware routes which return
null
are working as you expect, child routes are no longer executed in this case, useundefined
instead if necessary
4.3.0 - 2017-10-22
- Update path-to-regexp from v2.0.0 to v2.1.0, see changelog (#137)
4.2.1 - 2017-10-06
- Fix order of
context.keys
when they preserved from parent routes (i.e. keys order is the same as they appear in a url) (#129)
4.2.0 - 2017-09-20
- Correctly handle trailing slashes in paths of routes (#124)
If you are using trailing slashes in your paths, then the router will match urls only with trailing slashes:const routes = [ { path: '/posts', ... }, // matches both "/posts" and "/posts/" { path: '/posts/', ... }, // matches only "/posts/" ];
- Generate url from first path for routes with an array of paths (#124)
const router = new UniversalRouter({ name: 'page', path: ['/one', '/two', /RegExp/], // only first path is used for url generation }); const url = generateUrls(router); url('page'); // => /one
4.1.0 - 2017-09-20
- Support for using the same param name in array of paths (#122)
const router = new UniversalRouter({ path: ['/one/:parameter', '/two/:parameter'], action: context => context.params, }); router.resolve('/one/a'); // => { parameter: 'a' } router.resolve('/two/b'); // => { parameter: 'b' }
4.0.0 - 2017-09-15
- Rename
router.resolve({ path })
torouter.resolve({ pathname })
(BREAKING CHANGE #114) - Rename
context.url
tocontext.pathname
(BREAKING CHANGE #114) - Remove
pretty
option fromgenerateUrls(router, options)
function in favor of newencode
option (BREAKING CHANGE #111) - Update path-to-regexp to v2.0.0, see changelog (BREAKING CHANGE #111)
- Explicitly handle trailing delimiters (e.g.
/test/
is now treated as/test/
instead of/test
when matching) - No wildcard asterisk (
*
) - use parameters instead ((.*)
)
- Explicitly handle trailing delimiters (e.g.
- Add support for repeat parameters (#116)
- Add
encode
option togenerateUrls(router, options)
function for pretty encoding (e.g. pass your own implementation) (#111) - Preserve
context.keys
values from the parent route (#111) - Inherit
context.params
andqueryParams
from Object (e.g.params.hasOwnProperty()
won't throw an exception anymore) (#111) - Include the source code of the router in the npm package (#110)
Migration from v3 to v4:
- Change
router.resolve({ path, ... })
torouter.resolve({ pathname, ... })
- Remove trailing slashes from all paths of your routes, i.e.
path: '/posts/:uri/'
=>path: '/posts/:uri'
path: '/posts/'
=>path: '/posts'
path: '/'
=>path: ''
- etc.
- Replace
path: '*'
withpath: '(.*)'
if any - If you are using webpack, change rule (loader) for
.js
files to include.mjs
extension, i.e.test: /\.js$/
=>test: /\.m?js$/
3.2.0 - 2017-05-10
- Add
stringifyQueryParams
option togenerateUrls(router, options)
to generate URL with query string from unknown route params (#93)