Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,11 @@ def from_container_url(
container_url = "https://" + container_url
except AttributeError:
raise ValueError("Container URL must be a string.")
parsed_url = urlparse(container_url.rstrip('/'))
parsed_url = urlparse(container_url)
if not parsed_url.netloc:
raise ValueError("Invalid URL: {}".format(container_url))

container_path = parsed_url.path.lstrip('/').split('/')
container_path = parsed_url.path.strip('/').split('/')
account_path = ""
if len(container_path) > 1:
account_path = "/" + "/".join(container_path[:-1])
Expand Down
7 changes: 7 additions & 0 deletions sdk/storage/azure-storage-blob/tests/test_blob_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,13 @@ def test_create_service_with_custom_account_endpoint_path(self):
assert service.primary_hostname == 'local-machine:11002/custom/account/path'
assert service.url == 'http://local-machine:11002/custom/account/path/foo'

service = ContainerClient.from_container_url("http://local-machine:11002/custom/account/path/foo/?query=value")
assert service.account_name == None
assert service.container_name == "foo"
assert service.credential == None
assert service.primary_hostname == 'local-machine:11002/custom/account/path'
assert service.url == 'http://local-machine:11002/custom/account/path/foo'

service = BlobClient(account_url=custom_account_url, container_name="foo", blob_name="bar", snapshot="baz")
assert service.account_name == None
assert service.container_name == "foo"
Expand Down