0

Feeding this into switchPath

  const Routes = {
    "/": Home,
    "/login": Login,
    '*': function(){return {DOM: xs.of(<h1> 404</h1>)}}
  }

navigating to /lossgin will log that current route/path is "/".

bloodyKnuckles
  • 11,551
  • 3
  • 29
  • 37
janat08
  • 1,725
  • 2
  • 16
  • 27

1 Answers1

0

This appears to be a problem with switch-path. (And nothing to do with CycleJS history)

See this switch-path issue and this pull request.

Simply put, the wildcard * does not get captured when route '/' is in use and there are no nested routes. For example:

const { path, value } = switchPath("/lossgin", {
  "/": 123,
  "/login": 456,
  "*": 789
});

console.log(path, value) produces:

/ 123

A work-around is to change your login route to a nested route:

const { path, value } = switchPath("/lossgin", {
  "/": 123,
  "/login": {"/": 456}, // <-- nested route
  "*": 789
});

console.log(path, value) produces:

/lossgin 789

See code example here.

bloodyKnuckles
  • 11,551
  • 3
  • 29
  • 37
  • the nested route must remain at the very bottom of object or else everything below it becomes wildcard. – janat08 Oct 07 '18 at 00:10
  • @janat08 Additional specified routes, such as, `/home` need to occur in order before the nested route, but root, `/` can be listed after the nested route. – bloodyKnuckles Oct 08 '18 at 01:55