-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Dynamic Route Parameters Options #1268
Comments
Hmm. I'm not sure what's best here because the URL is ambiguous with respect to the pattern. In your case the request makes sense, but if someone else had |
One of the reasons for implementing route fallthrough was so that we could get rid of Sapper's regex route params. I don't have strong opinions about how to resolve this. Maybe it would be nice for SvelteKit to provide all different partitionings of the path and try them in some arbitrary order, but that sounds annoying. A simpler solution would be to pick one way to handle this, document it, and also document that if people want different behavior, they can use a single param for the folder name or filename and then do their own splitting and fall through if appropriate. |
I hadn't thought of the single param solution. I agree that's the best way to handle this and documenting it would be nice |
As @benmccann suggested, a single dynamic parameter can be matched against a regex in the Another possibility could be to specify a regex that |
We can already take advantage of fallthrough by not returning in the |
* test for split params ambiguous behaviour (#1268) * docs
Sorry to type in here again but this is not working for me: "We can already take advantage of fallthrough by not returning in the load function, so non-matches would already turn into a 404." Instead of falling back to 404 page it says: |
There's an open bug for that: #2041 |
Is your feature request related to a problem? Please describe.
So, I'm using a dynamic route in a file
/path/[slug]-[id].svelte
. If I navigate to/path/foo-1
, the variables are assigned as followsslug === "foo"
id === "1"
Instead, when I navigate to
/path/foo1-foo2-1
, then the variables are assigned as followsslug === "foo1"
id === "foo2-1"
Describe the solution you'd like
What I expect is for the first dynamic parameter to match the longest possible pattern. Otherwise, at least, have a way to specify it. For instance the regex
[a-zA-Z-]*-[a-zA-Z]
matches the pattern with the last characters after-
to be in the second part, but this is not a valid name for a file.Also, the docs IMHO could be more extensive regarding this subject.
Describe alternatives you've considered
One can match the entire part of the route and then split it.
The text was updated successfully, but these errors were encountered: