Skip to content

Commit

Permalink
Pull container name from URL for Azure blob in https://<account>.blob…
Browse files Browse the repository at this point in the history
….core.windows.net/<container> case (#5371)
  • Loading branch information
bradvoth authored Feb 8, 2024
1 parent 5572398 commit bc824d2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions object_store/src/azure/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ impl MicrosoftAzureBuilder {
/// - `azure://<container>/<path>` (custom)
/// - `https://<account>.dfs.core.windows.net`
/// - `https://<account>.blob.core.windows.net`
/// - `https://<account>.blob.core.windows.net/<container>`
/// - `https://<account>.dfs.fabric.microsoft.com`
/// - `https://<account>.dfs.fabric.microsoft.com/<container>`
/// - `https://<account>.blob.fabric.microsoft.com`
Expand Down Expand Up @@ -589,6 +590,9 @@ impl MicrosoftAzureBuilder {
"https" => match host.split_once('.') {
Some((a, "dfs.core.windows.net")) | Some((a, "blob.core.windows.net")) => {
self.account_name = Some(validate(a)?);
if let Some(container) = parsed.path_segments().unwrap().next() {
self.container_name = Some(validate(container)?);
}
}
Some((a, "dfs.fabric.microsoft.com")) | Some((a, "blob.fabric.microsoft.com")) => {
self.account_name = Some(validate(a)?);
Expand Down Expand Up @@ -984,6 +988,14 @@ mod tests {
assert_eq!(builder.account_name, Some("account".to_string()));
assert!(!builder.use_fabric_endpoint.get().unwrap());

let mut builder = MicrosoftAzureBuilder::new();
builder
.parse_url("https://account.blob.core.windows.net/container")
.unwrap();
assert_eq!(builder.account_name, Some("account".to_string()));
assert_eq!(builder.container_name, Some("container".to_string()));
assert!(!builder.use_fabric_endpoint.get().unwrap());

let mut builder = MicrosoftAzureBuilder::new();
builder
.parse_url("https://account.dfs.fabric.microsoft.com/")
Expand Down

0 comments on commit bc824d2

Please sign in to comment.