File tree 1 file changed +6
-2
lines changed
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 1
1
import base64
2
2
import os
3
+ import re
3
4
import tarfile
4
5
5
6
from io import BytesIO
@@ -101,11 +102,14 @@ def _make_response(
101
102
response .raw .write (file_handler .read ())
102
103
response .raw .seek (0 )
103
104
104
- url = urlparse (request .url )
105
105
if fixture_request .param == "response_url_with_credentials" :
106
106
response .url = request .url
107
107
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 )
109
113
response .reason = reason
110
114
return response
111
115
You can’t perform that action at this time.
0 commit comments