diff options
author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-01-18 19:11:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-18 19:11:18 +0100 |
commit | 23e886886249ebe8f80a48b0d25fbb5308eeb06f (patch) | |
tree | ddd2eb220750704fa4fbfd8447654fc3d382bd10 /django/http/request.py | |
parent | fd21f82aa82b0d75a161f618ef944ebe0923e0ab (diff) | |
download | django-23e886886249ebe8f80a48b0d25fbb5308eeb06f.tar.gz |
Refs #34233 -- Used str.removeprefix()/removesuffix().
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 |