@@ -678,7 +678,10 @@ impl MicrosoftAzureBuilder {
678678 "https" => match host. split_once ( '.' ) {
679679 Some ( ( a, "dfs.core.windows.net" ) ) | Some ( ( a, "blob.core.windows.net" ) ) => {
680680 self . account_name = Some ( validate ( a) ?) ;
681- if let Some ( container) = parsed. path_segments ( ) . unwrap ( ) . next ( ) {
681+ let container = parsed. path_segments ( ) . unwrap ( ) . next ( ) . expect (
682+ "iterator always contains at least one string (which may be empty)" ,
683+ ) ;
684+ if !container. is_empty ( ) {
682685 self . container_name = Some ( validate ( container) ?) ;
683686 }
684687 }
@@ -689,10 +692,11 @@ impl MicrosoftAzureBuilder {
689692 // - https://onelake.dfs.fabric.microsoft.com/<workspace>/<item>.<itemtype>/<path>/<fileName>
690693 //
691694 // See <https://learn.microsoft.com/en-us/fabric/onelake/onelake-access-api>
692- if let Some ( workspace) = parsed. path_segments ( ) . unwrap ( ) . next ( ) {
693- if !workspace. is_empty ( ) {
694- self . container_name = Some ( workspace. to_string ( ) )
695- }
695+ let workspace = parsed. path_segments ( ) . unwrap ( ) . next ( ) . expect (
696+ "iterator always contains at least one string (which may be empty)" ,
697+ ) ;
698+ if !workspace. is_empty ( ) {
699+ self . container_name = Some ( workspace. to_string ( ) )
696700 }
697701 self . use_fabric_endpoint = true . into ( ) ;
698702 }
@@ -1126,11 +1130,16 @@ mod tests {
11261130 assert_eq ! ( builder. account_name, Some ( "account" . to_string( ) ) ) ;
11271131 assert ! ( !builder. use_fabric_endpoint. get( ) . unwrap( ) ) ;
11281132
1129- let mut builder = MicrosoftAzureBuilder :: new ( ) ;
1133+ let mut builder =
1134+ MicrosoftAzureBuilder :: new ( ) . with_container_name ( "explicit_container_name" ) ;
11301135 builder
11311136 . parse_url ( "https://account.blob.core.windows.net/" )
11321137 . unwrap ( ) ;
11331138 assert_eq ! ( builder. account_name, Some ( "account" . to_string( ) ) ) ;
1139+ assert_eq ! (
1140+ builder. container_name,
1141+ Some ( "explicit_container_name" . to_string( ) )
1142+ ) ;
11341143 assert ! ( !builder. use_fabric_endpoint. get( ) . unwrap( ) ) ;
11351144
11361145 let mut builder = MicrosoftAzureBuilder :: new ( ) ;
0 commit comments