Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdk/core/azure-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

### Bugs Fixed

- Fixed `PipelineClient.format_url` to preserve trailing slash in the base URL when the URL template is query-string-only (e.g., `?key=value`). #45365

### Other Changes

## 1.38.2 (2026-02-18)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ def format_url(self, url_template: str, **kwargs: Any) -> str:
parsed = urlparse(url)
if not parsed.scheme or not parsed.netloc:
try:
base = self._base_url.format(**kwargs).rstrip("/")
base = self._base_url.format(**kwargs)
except KeyError as key:
err_msg = "The value provided for the url part {} was incorrect, and resulted in an invalid url"
raise ValueError(err_msg.format(key.args[0])) from key
Expand Down
8 changes: 8 additions & 0 deletions sdk/core/azure-core/tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,14 @@ def test_format_url_query_strings():
assert formatted == "https://foo.core.windows.net/Tables?a=X&c=Y"


def test_format_url_trailing_slash_preserved_with_query_only():
# Test that trailing slash in base URL is preserved when url_template is query-string only
# https://github.com/Azure/azure-sdk-for-python/issues/45365
client = PipelineClientBase("{url}")
formatted = client.format_url("?versionid=2026-02-25", url="https://storage.blob.core.windows.net/sample//a/a/")
assert formatted == "https://storage.blob.core.windows.net/sample//a/a/?versionid=2026-02-25"


def test_format_url_from_http_request():
client = PipelineClientBase("https://foo.core.windows.net")

Expand Down
Loading