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

xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new 737f55e2f chore(services/obs): Use QueryPairsWriter for url write 
(#5985)
737f55e2f is described below

commit 737f55e2fe4cc899c99c6d6fd58fa655938ff27d
Author: Asuka Minato <i...@asukaminato.eu.org>
AuthorDate: Wed Apr 9 12:46:08 2025 +0900

    chore(services/obs): Use QueryPairsWriter for url write (#5985)
    
    QueryPairsWriter
---
 core/src/services/obs/core.rs | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/core/src/services/obs/core.rs b/core/src/services/obs/core.rs
index f12c0a80c..0e68a68e0 100644
--- a/core/src/services/obs/core.rs
+++ b/core/src/services/obs/core.rs
@@ -291,28 +291,22 @@ impl ObsCore {
         limit: Option<usize>,
     ) -> Result<Response<Buffer>> {
         let p = build_abs_path(&self.root, path);
+        let mut url = QueryPairsWriter::new(&self.endpoint);
 
-        let mut queries = vec![];
         if !path.is_empty() {
-            queries.push(format!("prefix={}", percent_encode_path(&p)));
+            url = url.push("prefix", &percent_encode_path(&p));
         }
         if !delimiter.is_empty() {
-            queries.push(format!("delimiter={delimiter}"));
+            url = url.push("delimiter", delimiter);
         }
         if let Some(limit) = limit {
-            queries.push(format!("max-keys={limit}"));
+            url = url.push("max-keys", &limit.to_string());
         }
         if !next_marker.is_empty() {
-            queries.push(format!("marker={next_marker}"));
+            url = url.push("marker", next_marker);
         }
 
-        let url = if queries.is_empty() {
-            self.endpoint.to_string()
-        } else {
-            format!("{}?{}", self.endpoint, queries.join("&"))
-        };
-
-        let mut req = Request::get(&url)
+        let mut req = Request::get(url.finish())
             .body(Buffer::new())
             .map_err(new_request_build_error)?;
 

Reply via email to