This is an automated email from the ASF dual-hosted git repository.
tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/master by this push:
new ec788e15a9 Decode URL paths (#5017) (#5018)
ec788e15a9 is described below
commit ec788e15a99835376430b27617b1bb766709e05c
Author: Raphael Taylor-Davies <[email protected]>
AuthorDate: Wed Nov 1 14:33:47 2023 +0000
Decode URL paths (#5017) (#5018)
---
object_store/src/parse.rs | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/object_store/src/parse.rs b/object_store/src/parse.rs
index 51993e2455..0fbc33c935 100644
--- a/object_store/src/parse.rs
+++ b/object_store/src/parse.rs
@@ -98,8 +98,7 @@ impl ObjectStoreScheme {
_ => return Err(Error::Unrecognised { url: url.clone() }),
};
- let path = Path::parse(path)?;
- Ok((scheme, path))
+ Ok((scheme, Path::from_url_path(path)?))
}
}
@@ -240,6 +239,18 @@ mod tests {
),
("http://mydomain/path", (ObjectStoreScheme::Http, "path")),
("https://mydomain/path", (ObjectStoreScheme::Http, "path")),
+ (
+ "s3://bucket/foo%20bar",
+ (ObjectStoreScheme::AmazonS3, "foo bar"),
+ ),
+ (
+ "https://foo/bar%20baz",
+ (ObjectStoreScheme::Http, "bar baz"),
+ ),
+ (
+ "file:///bar%252Efoo",
+ (ObjectStoreScheme::Local, "bar%2Efoo"),
+ ),
];
for (s, (expected_scheme, expected_path)) in cases {
@@ -260,4 +271,12 @@ mod tests {
assert!(ObjectStoreScheme::parse(&url).is_err());
}
}
+
+ #[test]
+ fn test_url_spaces() {
+ let url = Url::parse("file:///my file with spaces").unwrap();
+ assert_eq!(url.path(), "/my%20file%20with%20spaces");
+ let (_, path) = parse_url(&url).unwrap();
+ assert_eq!(path.as_ref(), "my file with spaces");
+ }
}