mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
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).
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user