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

Nested routes with param prefix #134

Closed
frederikhors opened this issue Sep 15, 2020 · 1 comment · Fixed by #135
Closed

Nested routes with param prefix #134

frederikhors opened this issue Sep 15, 2020 · 1 comment · Fixed by #135
Labels
bug Something isn't working ready Change implemented in a dev branch
Milestone

Comments

@frederikhors
Copy link
Contributor

I have this situation:

  • / (Home)
  • /players - with const prefix = '/players' (it works)
    • /players/all
    • /players/create
    • /players/update/:ID
    • /players/:ID - Open.svelte (same file)
    • /players/:ID/* - Open.svelte (same file)
      • /players/:ID/team
      • /players/:ID/other

In Open.svelte what prefix should I have?

I tried like this:

const prefix = '/:ID'

const routes = {
  '/': SinglePlayer,
  '/team': Team
  '/other': Other
}

It doesn't work? Why?

It only works if I use const prefix = '/players' also in Open.svelte.

It's weird, right?

I wish I can use :ID as prefix.

@ItalyPaleAle
Copy link
Owner

The issue here is that /players/:id is actually converted to a regular expression, and that's why using that string as prefix fails.

I've fixed this in version 3.0 (WIP branch, planning to release within a couple of days). The way this will be fixed is by enabling you to define a regular that will be matched as prefix. In your case, you'll define prefix as:

const prefix = /^\/players\/(.*?)\//i

Once 3.0 is out (or you can try with the v3.0-wip branch today!) that will work

@ItalyPaleAle ItalyPaleAle added this to the v3.0 milestone Sep 19, 2020
@ItalyPaleAle ItalyPaleAle added bug Something isn't working ready Change implemented in a dev branch labels Sep 19, 2020
@ItalyPaleAle ItalyPaleAle mentioned this issue Sep 19, 2020
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready Change implemented in a dev branch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants