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

Bug: Blazor route discovery cannot discriminate subroutes after a parameter #35

Open
conficient opened this issue Jun 5, 2023 · 1 comment

Comments

@conficient
Copy link
Contributor

conficient commented Jun 5, 2023

A set of routes with different subroutes after a parameter overwrite previous routes causing mismatch.

In the BlazorRouteTests amend the code for MatchesTemplateWithParameters as follows:

        [Fact]
        public void MatchesTemplateWithParameters()
        {
            string[] templates =
            {
                "/Cats/{id}/Breed",
                "/Cats/{id}",
                "/Cats/{id}/Owner",
            };
            var target = new BlazorRoutes(templates);
            Assert.True(target.Contains("cats/42"));
            Assert.True(target.Contains("cats/42/owner"));
            Assert.True(target.Contains("cats/42/breed"));
        }

The first two tests pass but the second fails, because the last parameter route (owner) overwrites the prior one.

@conficient
Copy link
Contributor Author

Seems to be a logic error in RoutePart.cs when adding routes..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant