Fix overshadowing of overlapped subapp prefixes (#3701). #3708
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What do these changes do?
Fix for issue #3701 - overshadowing of overlapped subapp prefixes.
The fix allows different subapps to have prefixes with overlapping beginning. The following didn't work properly before - the second subapp prefix was hidden by the first one as subapp prefixes matching was performed by
startswith
only, so the first added app won:Are there changes in behavior for the user?
Subapps with overlapping prefixes can now be used without unexpected overshadowing.
Related issue number
#3701
Notes
I have considered storing the value of
self._prefix + '/'
in an attribute for optimization but was not sure to do that because it adds complexity. Please let me know if such optimization is desired - I can dig further.Without adding
request.url.raw_path != self._prefix
to the comparison the existing behavior of matching empty and root subapp routes would have changed. That didn't break any existing test though, so I have added 2 more tests to make sure this works as before -test_urldispatch.py/test_prefixed_subapp_empty_route
andtest_urldispatch.py/test_prefixed_subapp_root_route
Checklist
Please let me know if any documentation change is required.
CONTRIBUTORS.txt
CHANGES
folder