-
Notifications
You must be signed in to change notification settings - Fork 250
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
Incorrect route matching with subfolder root #275
Comments
Hey, if you ser a specific path as a root of your app you should skip it when writing URLs in the
The router knows that you mean |
Okay, thank you for the answer. Then, I believe that the Moreover, if you take away the root path, then it can be a bit confusing for the user in the browser .e.g.:
(I know, it's a minor detail) |
I'm a bit confused what is the expected behavior. Can you share a URL or even if possible a codesandbox. You can use this as an example https://codesandbox.io/s/navigo-example-jrui8 |
Essentially, I create a path via I think it would make more sense for the link to include the full path with the root as mentioned in the previous post. E.g. I could probably just take the root off the generated path programatically... I am just thinking out loud here :) The site is still WIP, but I am happy to share it at a later date (I think you'll find it interesting anyway as I use Navigo for an internationalisation system, including language change for the url path). |
I see @stepanjakl. I would rather patch the generate method so it returns the path without app than forcing the full url path on the links. Conceptually the idea of Navigo is to be an app oriented. It shouldn't know about the rest of the world. So I'll probably provide an additional argument to the generate function which will strip the root. |
Hi @krasimir, |
@stepanjakl @mrdaliri can you please try the latest 8.9.0 version. It allows a third argument of the router.generate(
"route-name",
{ data: 'foobar' }, // this cloud be null
{ includeRoot: false } // false means "Don't include the root"
) |
I swapped the project a custom domain (and root folder), so I cannot test it. But it looks good and would consider it fixed👍 |
Hello Krasimir,
I deployed a site on Github Pages inside a subfolder and set Navigo's root to that subfolder i.e.
new Navigo('/bohemica-studio-website')
.I am getting a wrong match for Navigo links when the
href
path is (correctly) set to"bohemica-studio-website/en/projects/branding"
. The matching route should bebohemica-studio-website/:language/projects/:name
, but it ends up beingbohemica-studio-website/*
.Interestingly, when I call the
router.match('bohemica-studio-website/en/projects/branding')
, I get the correct route. Same, when I set the link without the root path i.e."en/projects/branding"
Maybe, there is some wrong deployment setting, but I feel that Navigo is being fed the right data, so it's likely an internal issue. What do you think?
Thank you ✌️
P.S. Everything works fine on localhost when the root path is set to
'/'
The text was updated successfully, but these errors were encountered: