kriasoft / universal-router

A simple middleware-style router for isomorphic JavaScript web apps
https://www.kriasoft.com/universal-router/
MIT License
1.7k stars 104 forks source link

Fix the order of context.keys #129

Closed frenzzy closed 6 years ago

frenzzy commented 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:

const routes = {
  path: '/foo/:a/:b',
  action(context) {
    console.log(context.keys);
    // now and previously:
    // [
    //   { name: 'a', … },
    //   { name: 'b', … },
    // ]
  },
  children: [
    {
      path: '/bar/:c/:d',
      action(context) {
        console.log(context.keys);
        // now:
        // [
        //   { name: 'a', … },
        //   { name: 'b', … },
        //   { name: 'c', … },
        //   { name: 'd', … },
        // ]

        // previously:
        // [
        //   { name: 'c', … },
        //   { name: 'd', … },
        //   { name: 'a', … },
        //   { name: 'b', … },
        // ]
      },
    },
  ],
};
coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 625f3e0f5bfc522c7c369a164d8b2a0a910b2e1b on frenzzy:fix-context-keys into 28890a5fdac8ed1e4a87fc6146202fc39b8d1736 on kriasoft:master.