File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 11import base64
22import os
3+ import re
34import tarfile
45
56from io import BytesIO
@@ -101,11 +102,14 @@ def _make_response(
101102 response .raw .write (file_handler .read ())
102103 response .raw .seek (0 )
103104
104- url = urlparse (request .url )
105105 if fixture_request .param == "response_url_with_credentials" :
106106 response .url = request .url
107107 else :
108- response .url = request .url .replace (url .netloc , url .hostname )
108+ # Strip credentials using regex, preserving port if present:
109+ # ^([^:]+://) - Capture group 1: scheme (http:// or https://)
110+ # [^@]+@ - Match and remove credentials (anything up to @)
111+ # \1 - Replace with just the captured scheme
112+ response .url = re .sub (r"^([^:]+://)[^@]+@" , r"\1" , request .url )
109113 response .reason = reason
110114 return response
111115
You can’t perform that action at this time.
0 commit comments