Universal Router Versions Save

A simple middleware-style router for isomorphic JavaScript web apps

v6.0.0

6 years ago
  • No special configuration is required for your bundler anymore (say hi to parcel.js).
  • Add an option for global error handling (#147).

Migration from v5 to v6:

  • Use error.code instead of error.status or error.statusCode for error handling.

v5.1.0

6 years ago
  • Allow any string to be a valid route name (#145)

v5.0.0

6 years ago
  • 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 return undefined instead of null 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, use undefined instead if necessary

v4.3.0

6 years ago

v4.2.1

6 years ago
  • 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)

v4.2.0

6 years ago
  • 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
    

v4.1.0

6 years ago
  • 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' }
    

v4.0.0

6 years ago
  • Rename router.resolve({ path }) to router.resolve({ pathname }) (BREAKING CHANGE #114)
  • Rename context.url to context.pathname (BREAKING CHANGE #114)
  • Remove pretty option from generateUrls(router, options) function in favor of new encode 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 ((.*))
  • Add support for repeat parameters (#116)
  • Add encode option to generateUrls(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 and queryParams 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, ... }) to router.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: '*' with path: '(.*)' if any
  • If you are using webpack, change rule (loader) for .js files to include .mjs extension, i.e.
    • test: /\.js$/ => test: /\.m?js$/

v3.2.0

7 years ago
  • Add stringifyQueryParams option to generateUrls(router, options) to generate URL with query string from unknown route params (#93)

v3.1.0

7 years ago
  • Fix context.next() for multiple nested routes (#91)
  • Add pretty option for generateUrls(router, options) to prettier encoding of URI path segments (#88)
  • Add source maps for minified builds (#87)
  • Include UMD builds to the git repository