diff options
Diffstat (limited to 'django/http/request.py')
-rw-r--r-- | django/http/request.py | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/django/http/request.py b/django/http/request.py index 6b51d23e97..d451147bc1 100644 --- a/django/http/request.py +++ b/django/http/request.py @@ -242,9 +242,7 @@ class HttpRequest: # If location starts with '//' but has no netloc, reuse the # schema and netloc from the current request. Strip the double # slashes and continue as if it wasn't specified. - if location.startswith("//"): - location = location[2:] - location = self._current_scheme_host + location + location = self._current_scheme_host + location.removeprefix("//") else: # Join the constructed URL with the provided location, which # allows the provided location to apply query strings to the @@ -456,7 +454,7 @@ class HttpHeaders(CaseInsensitiveMapping): @classmethod def parse_header_name(cls, header): if header.startswith(cls.HTTP_PREFIX): - header = header[len(cls.HTTP_PREFIX) :] + header = header.removeprefix(cls.HTTP_PREFIX) elif header not in cls.UNPREFIXED_HEADERS: return None return header.replace("_", "-").title() @@ -724,7 +722,7 @@ def split_domain_port(host): bits = host.rsplit(":", 1) domain, port = bits if len(bits) == 2 else (bits[0], "") # Remove a trailing dot (if present) from the domain. - domain = domain[:-1] if domain.endswith(".") else domain + domain = domain.removesuffix(".") return domain, port |