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

redirect trailing slash with parameter goes into infinite loop. #2649

Open
schveiguy opened this issue May 5, 2022 · 1 comment
Open

redirect trailing slash with parameter goes into infinite loop. #2649

schveiguy opened this issue May 5, 2022 · 1 comment

Comments

@schveiguy
Copy link
Contributor

schveiguy commented May 5, 2022

Let's say I have a web interface that has the following routes:

/widget/:id/ (with int _id as a parameter)
/widget/foo

If I have those two routes in my web interface, then registerWebInterface registers 4 matching routes:

/widget/:id => redirect to /widget/:id/
/widget/:id/ => call method
/widget/foo/ => redirect to /widget/foo
/widget/foo => call method

If I go to /widget/foo, a surprising thing happens. The route matches /widget/:id because "foo" matches the :id placeholder, and therefore it redirects to /widget/foo/
The new request now matches the /widget/foo/, and redirects to /widget/foo, and it starts over again, in an endless loop.

What I would expect is that because the /widget/:id version expects an integer id, it should fail to match, and it should proceed to the true match.

@schveiguy
Copy link
Contributor Author

Thought about this, a solution could be to loop over the members twice, and add the redirects at the end. This way redirects are only chosen if the main routes don't match.

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