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

Cannot omit path as in the example code #11

Open
NeatSketch opened this issue Oct 8, 2020 · 0 comments
Open

Cannot omit path as in the example code #11

NeatSketch opened this issue Oct 8, 2020 · 0 comments

Comments

@NeatSketch
Copy link

In the README there is an example where a router object's add method is called with 1 argument:

users.add(function () {
  // create a new user
})

However, this doesn't work:

Uncaught TypeError: Cannot read property 'replace' of undefined
    at regexify (jouter.min.js:formatted:45)
    at routeRe (jouter.min.js:formatted:49)
    at route (jouter.min.js:formatted:53)
    at Function.add (jouter.min.js:formatted:94)
    at ...

Should this work or is there a mistake in the example code?


Also, what is the correct way to handle the following situation?

var rootRouter = jouter.createRouter();
var subRouter = jouter.createRouter();
rootRouter.add(router, '/mypage/...');

subRouter.add(function (x) {
    // Should be called on /mypage/foo/123
    // It works fine
}, '/foo/:x');

subRouter.add(function () {
    // Should be called on /mypage
    // ... but nothing happens
}, '/'); // I also tried '...', '/...', '*' but it doesn't work

I thought that maybe there should be no path specified (as in the example in the README), but the aforementioned error appeared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant