tustvold commented on code in PR #3424:
URL: https://github.com/apache/arrow-rs/pull/3424#discussion_r1059668165
##########
object_store/src/aws/mod.rs:
##########
@@ -465,44 +466,41 @@ impl AmazonS3Builder {
/// .with_url("s3://bucket/path")
/// .build();
/// ```
- pub fn with_url(mut self, url: impl AsRef<str>) -> Self {
- let maybe_parsed = Url::parse(url.as_ref());
- match maybe_parsed {
- Ok(parsed) => match parsed.scheme() {
- "s3" | "s3a" => {
- self.bucket_name = parsed.host_str().map(|host|
host.to_owned());
- }
- "https" => {
- if let Some(host) = parsed.host_str() {
- let parts = host.splitn(4, '.').collect::<Vec<&str>>();
- if parts.len() == 4 && parts[0] == "s3" && parts[2] ==
"amazonaws"
- {
- self.bucket_name = Some(parts[1].to_string());
- }
- if parts.len() == 4
- && parts[1] == "s3"
- && parts[3] == "amazonaws.com"
- {
- self.bucket_name = Some(parts[0].to_string());
- self.region = Some(parts[2].to_string());
- self.virtual_hosted_style_request = true;
- }
- }
- }
- other => {
- self.url_parse_error = Some(Error::UnknownUrlScheme {
- scheme: other.into(),
- });
- }
+ pub fn with_url(mut self, url: impl Into<String>) -> Self {
+ self.url = Some(url.into());
+ self
+ }
+
+ /// Sets properties on this builder based on a URL
+ ///
+ /// This is a separate member function to allow fallible computation to
+ /// be deferred until [`Self::build`] which in turn allows deriving
[`Clone`]
+ fn parse_url(&mut self, url: &str) -> Result<()> {
Review Comment:
Previously invalid URLs would be silently ignored, they now result in an
error which I think makes for a better UX
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]