Minor rfc3986 refactoring (#1157)

* Minor rfc3986 refactoring

* Update _models.py
This commit is contained in:
Tom Christie 2020-08-10 16:46:37 +01:00 committed by GitHub
parent 4cf74bc405
commit 7edfe64da6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -57,14 +57,14 @@ from ._utils import (
class URL:
def __init__(self, url: URLTypes = "", params: QueryParamTypes = None) -> None:
if isinstance(url, str):
self._uri_reference = rfc3986.api.iri_reference(url).encode()
self._uri_reference = rfc3986.iri_reference(url).encode()
if self.is_absolute_url:
# We don't want to normalize relative URLs, since doing so
# removes any leading `../` portion.
self._uri_reference = self._uri_reference.normalize()
else:
self._uri_reference = url._uri_reference
# Normalize scheme and domain name.
if self.is_absolute_url:
self._uri_reference = self._uri_reference.normalize()
# Add any query parameters, merging with any in the URL if needed.
if params:
if self._uri_reference.query: