Skip to content
Myr

Merge pull request #6644 from sigmavirus24/bug/6643

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trim excess leading path separators

authored by Ian Stapleton Cordasco · committed by GitHub · parents 382fc2c, 60389df · Browse files · 2 files+11 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+11 added−0 removed

  • tests:+8 added−0 removed
  • other:+3 added−0 removed

2 files+11 added−0 removed

modified:src/requests/adapters.py+3 added
388 unmodified lines
389 proxy_scheme = urlparse(proxy).scheme.lower()390 using_socks_proxy = proxy_scheme.startswith("socks")391392 url = request.path_url393 if url.startswith("//"): # Don't confuse urllib3394 url = f"/{url.lstrip('/')}"395396 if is_proxied_http_request and not using_socks_proxy:397 url = urldefragauth(request.url)398399 return url
141 unmodified lines
added:tests/test_adapters.py+8 added
1import requests.adapters234def test_request_url_trims_leading_path_separators():5 """See also https://github.com/psf/requests/issues/6643."""6 a = requests.adapters.HTTPAdapter()7 p = requests.Request(method="GET", url="http://127.0.0.1:10000//v:h").prepare()8 assert "/v:h" == a.request_url(p, {})