mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +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:
@@ -4,7 +4,7 @@ import re
|
||||
import unittest
|
||||
import zoneinfo
|
||||
from unittest import mock
|
||||
from urllib.parse import parse_qsl, urljoin, urlparse
|
||||
from urllib.parse import parse_qsl, urljoin, urlsplit
|
||||
|
||||
from django import forms
|
||||
from django.contrib import admin
|
||||
@@ -357,7 +357,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
|
||||
**save_option,
|
||||
},
|
||||
)
|
||||
parsed_url = urlparse(response.url)
|
||||
parsed_url = urlsplit(response.url)
|
||||
self.assertEqual(parsed_url.query, qsl)
|
||||
|
||||
def test_change_query_string_persists(self):
|
||||
@@ -386,7 +386,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
|
||||
**save_option,
|
||||
},
|
||||
)
|
||||
parsed_url = urlparse(response.url)
|
||||
parsed_url = urlsplit(response.url)
|
||||
self.assertEqual(parsed_url.query, qsl)
|
||||
|
||||
def test_basic_edit_GET(self):
|
||||
@@ -8032,11 +8032,11 @@ class AdminKeepChangeListFiltersTests(TestCase):
|
||||
Assert that two URLs are equal despite the ordering
|
||||
of their querystring. Refs #22360.
|
||||
"""
|
||||
parsed_url1 = urlparse(url1)
|
||||
parsed_url1 = urlsplit(url1)
|
||||
path1 = parsed_url1.path
|
||||
parsed_qs1 = dict(parse_qsl(parsed_url1.query))
|
||||
|
||||
parsed_url2 = urlparse(url2)
|
||||
parsed_url2 = urlsplit(url2)
|
||||
path2 = parsed_url2.path
|
||||
parsed_qs2 = dict(parse_qsl(parsed_url2.query))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user