mirror of https://github.com/scrapy/scrapy.git
Fix strip_url() removing default port from password. (#7605)
This commit is contained in:
parent
3a36955261
commit
f63a3aff25
|
|
@ -139,7 +139,8 @@ def strip_url(
|
||||||
("ftp", 21),
|
("ftp", 21),
|
||||||
}
|
}
|
||||||
):
|
):
|
||||||
netloc = netloc.replace(f":{parsed_url.port}", "")
|
port_suffix = f":{parsed_url.port}"
|
||||||
|
netloc = netloc.removesuffix(port_suffix)
|
||||||
|
|
||||||
return urlunparse(
|
return urlunparse(
|
||||||
(
|
(
|
||||||
|
|
|
||||||
|
|
@ -346,6 +346,18 @@ class TestStripUrl:
|
||||||
"ftp://username:password@www.example.com:221/file.txt",
|
"ftp://username:password@www.example.com:221/file.txt",
|
||||||
"ftp://username:password@www.example.com:221/file.txt",
|
"ftp://username:password@www.example.com:221/file.txt",
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
"http://user:80@www.example.com:80/index.html",
|
||||||
|
"http://user:80@www.example.com/index.html",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"https://user:443@www.example.com:443/index.html",
|
||||||
|
"https://user:443@www.example.com/index.html",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"ftp://user:21@www.example.com:21/file.txt",
|
||||||
|
"ftp://user:21@www.example.com/file.txt",
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_default_ports(self, url: str, expected: str) -> None:
|
def test_default_ports(self, url: str, expected: str) -> None:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue