question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

root path gives me the same behavior with *

See original GitHub issue

I am having trouble with the following code : When I type the following url ‘/v1/a/b/c’, I’d like to match the “not found” handler. Instead, I match the root path that I defined at last (‘/’). It’s like I would have defined it that way : ‘/*’.

var router = new Navigo('/v1');

router.on('modify', function () {
    setContent('modify');
})
.on('modify/:name', function (params, query) {
    setContent('name');
})
.on('/', function () {
    setContent('home');
})
router.notFound(function () {
    console.log("not found");
    // called when there is path specified but
    // there is no route matching
});
router.resolve();

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:17 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
sergiopvilarcommented, Jan 31, 2017

@richardsimko solved by using:

new Navigo(location.protocol + "//" + location.host, false)

0reactions
krasimircommented, Mar 25, 2017

@finppp I added a test case and it seems that I can’t reproduce the bug. Is Navigo operating at the very top folder of your site. I mean is it like under site.com/... or it is somewhere deeper like site.com/web/app/....

Here’s the test which had to reproduce the bug:

describe('and the problem described in issue #56-2', function () {
  it('should fire the notFound handler', function () {
    var router = new Navigo(null, false, '#!');
    var notFoundHandler = sinon.spy();
    var homeHandler = sinon.spy();
    var postsHandler = sinon.spy();

    router
      .notFound(notFoundHandler)
      .on({
        '/': homeHandler,
        '/my-posts': postsHandler
      });

    router.resolve();
    router.resolve('asdf');

    expect(homeHandler).to.be.calledOnce;
    expect(notFoundHandler).to.be.calledOnce;
  });
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Maintain path relative to root folder · Issue #174 - GitHub
It should be in a completely different folder from the root itself. This way the action doesn't find any least common ancestor of...
Read more >
How does the content root path work in .NET 6? - Stack Overflow
The web root path defaults to {content root}/wwwroot . In Razor . cshtml files, ~/ points to the web root.
Read more >
Relative and absolute paths, in the file system and on the web ...
If the path is built starting from the system root, it is called absolute. If the path is built starting from the current...
Read more >
DBX Root Header Modes Guide - Developers - Dropbox.com
Path Root Header Modes​​ This means that relative paths are evaluated relative to this location, and paths outside of this location are not...
Read more >
Quick Reminder About File Paths | CSS-Tricks
Starting with “/” returns to the root directory and starts there · Starting with “../” moves one directory backwards and starts there ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found