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

Router doesn't support dynamic parameter before dynamic segment #228

Closed
arctic-hen7 opened this issue Sep 9, 2021 · 4 comments · Fixed by #234
Closed

Router doesn't support dynamic parameter before dynamic segment #228

arctic-hen7 opened this issue Sep 9, 2021 · 4 comments · Fixed by #234
Assignees
Labels
A-router Area: router C-bug Category: bug, something isn't working

Comments

@arctic-hen7
Copy link
Contributor

Describe the bug
Sycamore's router doesn't seem to handle the case of a route that has a dynamic parameter (e.g. <locale>) before a dynamic segment (e.g. <slug..>), producing the error mismatch between number of capture fields and variant fields.

To Reproduce
Steps to reproduce the behavior:

Add the following lines to a router (en example I was working with):

#[to("/<locale>/post/<slug..>")]
Post { locale: String, slug: Vec<String> },

Expected behavior
Sycamore should accept the route as valid rather than generating a compile-time error.

Environment

  • Sycamore: v0.5.2 (within Perseus)

Additional context
Interestingly, the route /post/<slug..>/<locale> works (with the variants in a different order), so it seems that dynamic paths are supported after dynamic segments, but not before.

@arctic-hen7 arctic-hen7 added the C-bug Category: bug, something isn't working label Sep 9, 2021
@lukechu10 lukechu10 added the A-router Area: router label Sep 10, 2021
@lukechu10 lukechu10 self-assigned this Sep 11, 2021
@lukechu10
Copy link
Member

Found the issue. It's a parser error. Basically, the route /<param>/<segments..> is parsed as:

RoutePathAst {
    segments: [
        DynSegments(
            "param>/<segments",
        ),
    ],
}

@arctic-hen7
Copy link
Contributor Author

Fantastic! To clarify, is it just an error in the proc macros then? Or does it affect the lower-level path matching systems?

@lukechu10
Copy link
Member

Fantastic! To clarify, is it just an error in the proc macros then? Or does it affect the lower-level path matching systems?

It's just an issue with the proc-macro because the routes are parsed at compile-time. Should be fixed now. I'll try to release 0.6.0 tomorrow.

@arctic-hen7
Copy link
Contributor Author

Great, everything shouldn't blow up in my face when I try my custom routing systems then! Wow, that's fantastic! I look forward to it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-router Area: router C-bug Category: bug, something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants