mefechoel / svelte-navigator

Simple, accessible routing for Svelte
Other
502 stars 39 forks source link

A route with a path parameter is not matched if the path parameter value contains a dot #56

Closed Maritims closed 2 years ago

Maritims commented 2 years ago

When you have a route with a path parameter you won't be able to navigate to the route if your path parameter value contains a dot.

Steps to reproduce the behavior:

  1. Create a route which expects a path parameter, for instance "/foo/:bar"
  2. Attempt to access the route in your browser by going to for instance "/foo/bar.baz"
  3. Experience a 404 error

Expected behavior

As the dot character is not a reserved sign it does not need to be URL encoded. I expect to be able to navigate to a route with a path parameter value containing a dot.

mefechoel commented 2 years ago

I tried this quickly in the repl and I can't reproduce the error. But since you mention a 404 error, could it be that your server is not correctly setup for single page routing? Are you experiencing the issue in your dev environment? If so, what dev setup are you using? If you're using sirv, try passing the --single flag to it.

Maritims commented 2 years ago

@mefechoel I am indeed experiencing this in my dev environment. I gotta admit, Svelte is still pretty new to me but I was under the impression that I had the correct configuration for single page routing.

I tried adding the --single flag to the sirv call in my rollup.config.js now and that solved it. I see it's referenced in the project readme and I'd forgotten to do that.

Thanks! :)