Skip to content

Releases: nkbt/component-router

v3.1.1

02 Oct 02:55

Choose a tag to compare

New feature: wildcard :* routes

  • #116 Add wildcard routes support
  • #117 Fix trailing slash behaviour

Description

Added special wildcard param ":*", can be followed by named params, or other sub-path, or left as the rightmost param to match all.

First matching route wins, so they should be ordered from the most specific to the least specific in case of overlap

For this list of routes:

[
  '/',
  '/foo',
  '/foo/:*/:something/more',
  '/foo/:*/:something',
  '/foo/:*',
  '/bar/:*',
  '/cleanHistory'
]

These matches will be found based on URL

http://localhost:8080/bar

{
  "currentRoute": {
    "route": "/bar/:*",
    "regex": "^/bar(.*)/*$",
    "params": {
      "*": ""
    }
  }
}

http://localhost:8080/bar/

{
  "currentRoute": {
    "route": "/bar/:*",
    "regex": "^/bar(.*)/*$",
    "params": {
      "*": ""
    }
  }
}

http://localhost:8080/bar/x/z

  {
    "currentRoute": {
      "route": "/bar/:*",
      "regex": "^/bar(.*)/*$",
      "params": {
        "*": "/x/z"
      }
    }
  }

http://localhost:8080/foo

{
  "currentRoute": {
    "route": "/foo",
    "regex": "^/foo/*$",
    "params": {}
  }
}

http://localhost:8080/foo/

{
  "currentRoute": {
    "route": "/foo",
    "regex": "^/foo/*$",
    "params": {}
  }
}

http://localhost:8080/foo//////

{
  "currentRoute": {
    "route": "/foo",
    "regex": "^/foo/*$",
    "params": {}
  }
}

http://localhost:8080/foo/x/z

{
  "currentRoute": {
    "route": "/foo/:*/:something",
    "regex": "^/foo(.*)/([^/]+)/*$",
    "params": {
      "*": "/x",
      "something": "z"
    }
  }
}

http://localhost:8080/foo/whatever

{
  "currentRoute": {
    "route": "/foo/:*",
    "regex": "^/foo(.*)/*$",
    "params": {
      "*": "/whatever"
    }
  }
}

http://localhost:8080/foo/x/z/more

{
  "currentRoute": {
    "route": "/foo/:*/:something/more",
    "regex": "^/foo(.*)/([^/]+)/more/*$",
    "params": {
      "*": "/x",
      "something": "z"
    }
  }
}

http://localhost:8080/foo/x/z/more////

{
  "currentRoute": {
    "route": "/foo/:*/:something/more",
    "regex": "^/foo(.*)/([^/]+)/more/*$",
    "params": {
      "*": "/x",
      "something": "z"
    }
  }
}

http://localhost:8080/foo//////x/z/more

{
  "currentRoute": {
    "route": "/foo/:*/:something/more",
    "regex": "^/foo(.*)/([^/]+)/more/*$",
    "params": {
      "*": "//////x",
      "something": "z"
    }
  }
}

v3.0.3

23 Oct 06:11

Choose a tag to compare

Fix

  • Fixed missing build

v3.0.2

23 Oct 06:04

Choose a tag to compare

Chore

v3.0.1

15 May 07:00

Choose a tag to compare

v3.0.0

15 May 04:06

Choose a tag to compare

  • Cleanup README to avoid any 2.x stuff
  • Remove official Bower support
  • Update build

v3.0.0-alpha.15

15 May 04:05

Choose a tag to compare

  • Add "off-record" param, to avoid adding items to history (use replace history instead of push)
  • Fix node adaptor

v3.0.0-alpha.14

07 Sep 02:00

Choose a tag to compare

  • Allow to skip adding browser history entries #105 thanks to @chalabov

v3.0.0-alpha.12

27 Apr 01:43

Choose a tag to compare

  • [FIX] #98 State should not be replaced if no changes
  • [FIX] #96 If you navigate away page with query params you have to click back twice to get back

v3.0.0-alpha.11

06 Apr 00:23

Choose a tag to compare

Breaking:

  • Remove store (actually moved to example), not a concern of this library
  • Add redux.combineReducers support with default state namespace componentRouter

Other:

  • Deps updates

v3.0.0-alpha.10

29 Mar 05:33

Choose a tag to compare

  • Adapter for node #92

    import {componentRouter, locationNode} from 'component-router';
    import {createStore} from 'redux';
    
    
    app.use((req, res, next) => {
      req.store = createStore(componentRouter)
      locationNode({store: req.store, routes: ['/', '/login', '/user']})(req);
      next();
    })