Skip to content

Commit 5d8bb45

Browse files
Copilotl0lawrence
andcommitted
Refine format_url fix: only preserve trailing slash for query-string-only stubs
Co-authored-by: l0lawrence <[email protected]>
1 parent fcaf7bc commit 5d8bb45

File tree

1 file changed

+5
-0
lines changed
  • sdk/core/azure-core/azure/core/pipeline/transport

1 file changed

+5
-0
lines changed

sdk/core/azure-core/azure/core/pipeline/transport/_base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,11 @@ def format_url(self, url_template: str, **kwargs: Any) -> str:
668668
err_msg = "The value provided for the url part {} was incorrect, and resulted in an invalid url"
669669
raise ValueError(err_msg.format(key.args[0])) from key
670670

671+
# Only strip trailing slash from base when stub has a path component.
672+
# For query-string-only stubs (e.g. "?key=val"), preserve any trailing
673+
# slash so it appears before the query string in the final URL.
674+
if url.split("?", 1)[0]:
675+
base = base.rstrip("/")
671676
url = _urljoin(base, url)
672677
else:
673678
url = self._base_url.format(**kwargs)

0 commit comments

Comments
 (0)