diff options
Diffstat (limited to 'django/urls/resolvers.py')
| -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 5b722474c9..3f8f6c00ea 100644 --- a/django/urls/resolvers.py +++ b/django/urls/resolvers.py @@ -147,7 +147,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 @@ -230,7 +234,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 |
