Use str as default path converter#9066
Conversation
| else: | ||
| self._base_pattern = '<{lookup_value}:{lookup_prefix}{lookup_url_kwarg}>' | ||
| self._default_value_pattern = 'path' | ||
| self._default_value_pattern = 'str' |
There was a problem hiding this comment.
Here they are: I have added the corner case in which there may be some patterns which may be ambigouus.
Thus using the <path:var> could cause problems, since it is too greedy, and having the latest registered pattern to never match if there is any sub-match.
|
str - Matches any non-empty string, excluding the path separator, '/'. This is the default if a converter isn’t included in the expression. can you weigh in a bit more in the context? |
|
Consider the test viewset The url-patterns produced by the router for this are going to be: The second pattern with Since the router follows this sequence to build patterns:
The problem arises when there are both default detail and any action detail. Since the first pattern ( An other way to avoid such confusion would be to change the order of routes in As final note the We may also register a custom path converter for rest-framework to match the pattern |
Description
Improves #6789 by using
stras default path converter instead ofpath.This because re-reading the docs the more appropriate to use is
str.This because its regex is
[^/]+which, among converters, is the most similar to the default used by router ([^/.]+).