Releases: kriasoft/universal-router
Releases · kriasoft/universal-router
Release list
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.urltocontext.pathname(BREAKING CHANGE #114) - Remove
prettyoption fromgenerateUrls(router, options)function in favor of newencodeoption (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/testwhen matching) - No wildcard asterisk (
*) - use parameters instead ((.*))
- Explicitly handle trailing delimiters (e.g.
- Add support for repeat parameters (#116)
- Add
encodeoption togenerateUrls(router, options)function for pretty encoding (e.g. pass your own implementation) (#111) - Preserve
context.keysvalues from the parent route (#111) - Inherit
context.paramsandqueryParamsfrom 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
.jsfiles to include.mjsextension, i.e.test: /\.js$/=>test: /\.m?js$/
3.2.0 - 2017-05-10
- Add
stringifyQueryParamsoption togenerateUrls(router, options)to generate URL with query string from unknown route params (#93)
3.1.0 - 2017-04-20
3.0.0 - 2017-03-25
- Update Router API (BREAKING CHANGE)
See #83 for more info and examples
import Router from 'universal-router'; const router = new Router(routes, options); router.resolve({ path, ...context }); // => Promise<any> // previously import { resolve } from 'universal-router'; resolve(routes, { path, ...context }); // => Promise<any>
context.next()now iterates only child routes by default (BREAKING CHANGE)
usecontext.next(true)to iterate through the all remaining routes- Remove
babel-runtimedependency to decrease library size (BREAKING CHANGE)
Now you need to care about these polyfills yourself: - Add support for URL Generation
import generateUrls from 'universal-router/generate-urls'; const url = generateUrls(router); url(routeName, params); // => String
- Add support for Dynamic Breadcrumbs, use
context.route.parentto iterate - Add support for Declarative Routes
new Router(routes, { resolveRoute: customResolveRouteFn });
- Add support for Base URL option
new Router(routes, { baseUrl: '/base' });
- Add ability to specify custom context properties once
new Router(routes, { context: {/* ... */} });
- Rewrite
matchRoutefunction without usage of generators to decrease amount of necessary polyfills - Remove usage of String.prototype.startsWith()
- Add
context.urlwith the original url passed toresolvemethod - Add
contextproperty toRoute not founderror
2.0.0 - 2016-10-20
- Preserve
context.paramsvalues from the parent route (#57) - Throws an error if no route found (#62)
- Remove obsolete
context.end()method (#60) - Remove obsolete
matchalias forresolvefunction (#59) - Do not throw an error for malformed URI params (#54)
- Handle
nullthe same way asundefined(#51) - Return
nullinstead ofundefinedto signal no match (#51) - Support
context.next()across multiple routes (#49) - Sequential execution of asynchronous routes (#49)
- Remove errors handler from core (#48)
- Drop support of node.js v5 and below (#47)
1.2.2 - 2016-05-31
- Update UMD build to include missing dependencies (#33)
1.2.1 - 2016-05-12
- Rename
src/browser.jstosrc/main.js
1.2.0 - 2016-05-12
- Rename
match()toresolve(). E.g.import { resovle } from 'universal-router' - Fix an issue when the router throws an exception when the top-level route doesn't have
childrenproperty - Include CommonJS, Harmony Modules, ES5.1 and UMD builds into NPM package
- Include source maps into NPM package
1.1.0-beta.4 - 2016-04-27
- Fix optional parameters, e.g.
/products/:id?(#27)