Skip to content

"any" routing bug if path and any route share prefix #1739

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

Closed
stffabi opened this issue Dec 29, 2020 · 0 comments · Fixed by #1741
Closed

"any" routing bug if path and any route share prefix #1739

stffabi opened this issue Dec 29, 2020 · 0 comments · Fixed by #1741

Comments

@stffabi
Copy link
Contributor

stffabi commented Dec 29, 2020

Issue Description

#1563 introduced a bug where the wrong route is selected if there's an any route for a folder e.g. /users/* and a requested path has the folder as a prefix e.g. /users_prefix/.

Having the following two any routes registered:
/*
/users/*

Expected behaviour

GET /users => /*
GET /users/ => /users/*
GET /users_prefix => /*
GET /users_prefix/ => /*

Actual behaviour

GET /users => /*
GET /users/ => /users/*
GET /users_prefix => /*
GET /users_prefix/ => /users/* which is wrong

Version/commit

6119aec

stffabi added a commit to stffabi/echo that referenced this issue Jan 3, 2021
lammel pushed a commit that referenced this issue Jan 3, 2021
* Add tests for issue #1739
* Handle special trailing slash case only for a matching prefix

Only handle the special trailing slash case if the whole prefix matches to avoid matching   
a wrong route for overlapping prefixes, e.g. /users/* for the path /users_prefix/ where
the route is only a partial prefix of the requested path.
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

Successfully merging a pull request may close this issue.

1 participant