Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(services/s3): omit default ports #4379

Merged
merged 3 commits into from
Mar 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions core/src/services/s3/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use std::collections::HashMap;
use std::fmt::Debug;
use std::fmt::Formatter;
use std::fmt::Write;
use std::str::FromStr;
use std::sync::atomic::AtomicBool;
use std::sync::Arc;

Expand All @@ -37,6 +38,7 @@ use reqsign::AwsConfig;
use reqsign::AwsCredentialLoad;
use reqsign::AwsDefaultLoader;
use reqsign::AwsV4Signer;
use reqwest::Url;
use serde::Deserialize;

use super::core::*;
Expand Down Expand Up @@ -628,6 +630,12 @@ impl S3Builder {
// If endpoint contains bucket name, we should trim them.
endpoint = endpoint.replace(&format!("//{bucket}."), "//");

// Omit default ports if specified.
if let Ok(url) = Url::from_str(&endpoint) {
// Remove the trailing `/` of root path.
endpoint = url.to_string().trim_end_matches('/').to_string();
}

// Update with endpoint templates.
endpoint = if let Some(template) = ENDPOINT_TEMPLATES.get(endpoint.as_str()) {
template.replace("{region}", region)
Expand Down
Loading