Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrected Azure Blob URI regex matching if the blob include some prefix #654

Merged
merged 1 commit into from
May 1, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion papermill/abs.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def _split_url(self, url):
see: https://docs.microsoft.com/en-us/azure/storage/common/storage-dotnet-shared-access-signature-part-1 # noqa: E501
abs://myaccount.blob.core.windows.net/sascontainer/sasblob.txt?sastoken
"""
match = re.match(r"abs://(.*)\.blob\.core\.windows\.net\/(.*)\/(.*)\?(.*)$", url)
match = re.match(r"abs://(.*)\.blob\.core\.windows\.net\/(.*?)\/(.*)\?(.*)$", url)
if not match:
raise Exception("Invalid azure blob url '{0}'".format(url))
else:
Expand Down
9 changes: 9 additions & 0 deletions papermill/tests/test_abs.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ def test_split_url_splits_valid_url(self):
self.assertEqual(params["blob"], "sasblob.txt")
self.assertEqual(params["sas_token"], "sastoken")

def test_split_url_splits_valid_url_with_prefix(self):
params = AzureBlobStore._split_url(
"abs://myaccount.blob.core.windows.net/sascontainer/A/B/sasblob.txt?sastoken"
)
self.assertEqual(params["account"], "myaccount")
self.assertEqual(params["container"], "sascontainer")
self.assertEqual(params["blob"], "A/B/sasblob.txt")
self.assertEqual(params["sas_token"], "sastoken")

def test_listdir_calls(self):
self.assertEqual(
self.abs.listdir(
Expand Down