This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs-object-store.git


The following commit(s) were added to refs/heads/main by this push:
     new f5b61ab  Support R2 URLs with jurisdictions (#815)
f5b61ab is described below

commit f5b61ab5f4e9b9ab2f3e62feaf3685f4d638b53a
Author: Nazar Vinnichuk <[email protected]>
AuthorDate: Tue Aug 18 00:19:41 2026 +0300

    Support R2 URLs with jurisdictions (#815)
---
 src/aws/builder.rs | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/src/aws/builder.rs b/src/aws/builder.rs
index b09c665..4b6e899 100644
--- a/src/aws/builder.rs
+++ b/src/aws/builder.rs
@@ -628,6 +628,7 @@ impl AmazonS3Builder {
     /// - `https://s3.dualstack.<region>.amazonaws.com/<bucket>`
     /// - `https://<bucket>.s3.dualstack.<region>.amazonaws.com`
     /// - `https://ACCOUNT_ID.r2.cloudflarestorage.com/bucket`
+    /// - `https://ACCOUNT_ID.JURISDICTION.r2.cloudflarestorage.com/bucket`
     ///
     /// Note: Settings derived from the URL will override any others set on 
this builder
     ///
@@ -852,6 +853,17 @@ impl AmazonS3Builder {
                         self.bucket_name = Some(bucket.into());
                     }
                 }
+                Some((account, jurisdiction, "r2", "cloudflarestorage.com")) 
=> {
+                    self.region = Some("auto".to_string());
+                    let endpoint =
+                        
format!("https://{account}.{jurisdiction}.r2.cloudflarestorage.com";);
+                    self.endpoint = Some(endpoint);
+
+                    let bucket = 
parsed.path_segments().into_iter().flatten().next();
+                    if let Some(bucket) = bucket {
+                        self.bucket_name = Some(bucket.into());
+                    }
+                }
                 _ => return Err(Error::UrlNotRecognised { url: url.into() 
}.into()),
             },
             scheme => {
@@ -1846,6 +1858,18 @@ mod tests {
             Some("https://account123.r2.cloudflarestorage.com".to_string())
         );
 
+        let mut builder = AmazonS3Builder::new();
+        builder
+            
.parse_url("https://account123.eu.r2.cloudflarestorage.com/bucket-123";)
+            .unwrap();
+
+        assert_eq!(builder.bucket_name, Some("bucket-123".to_string()));
+        assert_eq!(builder.region, Some("auto".to_string()));
+        assert_eq!(
+            builder.endpoint,
+            Some("https://account123.eu.r2.cloudflarestorage.com".to_string())
+        );
+
         let err_cases = [
             "mailto://bucket/path";,
             "https://s3.bucket.mydomain.com";,
@@ -1853,6 +1877,7 @@ mod tests {
             "https://bucket.mydomain.region.amazonaws.com";,
             "https://bucket.s3.region.bar.amazonaws.com";,
             "https://bucket.foo.s3.amazonaws.com";,
+            "https://account.r2.eu.cloudflarestorage.com/bucket";,
         ];
         let mut builder = AmazonS3Builder::new();
         for case in err_cases {

Reply via email to