From ff308a06047cd60806d604a7cf612e5656ee2ac9 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 29 May 2024 14:48:27 +0100 Subject: Fixed 35467 -- Replaced urlparse with urlsplit where appropriate. This work should not generate any change of functionality, and `urlsplit` is approximately 6x faster. Most use cases of `urlparse` didn't touch the path, so they can be converted to `urlsplit` without any issue. Most of those which do use `.path`, simply parse the URL, mutate the querystring, then put them back together, which is also fine (so long as urlunsplit is used). --- docs/ref/urlresolvers.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs/ref') diff --git a/docs/ref/urlresolvers.txt b/docs/ref/urlresolvers.txt index eb0b991f1b..b335d1fc39 100644 --- a/docs/ref/urlresolvers.txt +++ b/docs/ref/urlresolvers.txt @@ -203,7 +203,7 @@ A :class:`ResolverMatch` object can also be assigned to a triple:: One possible use of :func:`~django.urls.resolve` would be to test whether a view would raise a ``Http404`` error before redirecting to it:: - from urllib.parse import urlparse + from urllib.parse import urlsplit from django.urls import resolve from django.http import Http404, HttpResponseRedirect @@ -215,7 +215,7 @@ view would raise a ``Http404`` error before redirecting to it:: # modify the request and response as required, e.g. change locale # and set corresponding locale cookie - view, args, kwargs = resolve(urlparse(next)[2]) + view, args, kwargs = resolve(urlsplit(next).path) kwargs["request"] = request try: view(*args, **kwargs) -- cgit v1.3