diff options
Diffstat (limited to 'django/urls')
| -rw-r--r-- | django/urls/resolvers.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/django/urls/resolvers.py b/django/urls/resolvers.py index e565d34b27..abf0a11572 100644 --- a/django/urls/resolvers.py +++ b/django/urls/resolvers.py @@ -153,7 +153,11 @@ class RegexPattern(CheckURLMixin): self.converters = {} def match(self, path): - match = self.regex.search(path) + match = ( + self.regex.fullmatch(path) + if self._is_endpoint and self.regex.pattern.endswith('$') + else self.regex.search(path) + ) if match: # If there are any named groups, use those as kwargs, ignoring # non-named groups. Otherwise, pass all non-named arguments as @@ -240,7 +244,7 @@ def _route_to_regex(route, is_endpoint=False): converters[parameter] = converter parts.append('(?P<' + parameter + '>' + converter.regex + ')') if is_endpoint: - parts.append('$') + parts.append(r'\Z') return ''.join(parts), converters |
