Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump path-to-regexp, major changes #111

Merged
merged 1 commit into from Sep 8, 2017

Conversation

frenzzy
Copy link
Member

@frenzzy frenzzy commented Sep 7, 2017

  • Update path-to-regexp to v2.0.0, see changelog (BREAKING CHANGE)
    • Explicitly handle trailing delimiters (e.g. /test/ is now treated as /test/ instead of /test when matching)
    • No wildcard asterisk (*) - use parameters instead ((.*))
  • Add encode option to generateUrls(router, options) function for pretty encoding
    (e.g. pass your own implementation)
    import UniversalRouter from 'universal-router';
    import generateUrls from 'universal-router/generateUrls';
    
    const router = new UniversalRouter([
      { name: 'home', path: '/', },
      { name: 'user', path: '/user/:username' },
    ]);
    
    const url = generateUrls(router); // uses encodeURIComponent by default
    const prettyUrl = generateUrls(router, { encode: x => x });
    
    url('user', { username: ':/' });       // => '/user/%3A%2F'
    prettyUrl('user', { username: ':/' }); // => '/user/:/'
  • Remove pretty option from generateUrls(router, options) function in favor of new encode option
  • Preserve context.keys values from the parent route
  • Inherit context.params and queryParams from Object (e.g. params.hasOwnProperty() won't throw an exception anymore), fixes Replace "params = Object.create(null)" with "params = {}" #106

@coveralls
Copy link

coveralls commented Sep 7, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 65d3613 on frenzzy:path-to-regexp-v2 into 7883e10 on kriasoft:master.

@frenzzy frenzzy merged commit ac3b903 into kriasoft:master Sep 8, 2017
@frenzzy frenzzy deleted the path-to-regexp-v2 branch September 8, 2017 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace "params = Object.create(null)" with "params = {}"
2 participants