diff options
| author | Joon Young Baik <110450904+baikjy0215@users.noreply.github.com> | 2025-07-11 00:50:20 +1200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-10 05:50:20 -0700 |
| commit | c04b7b411c6eafd2c9ae15ce68a907a02541df83 (patch) | |
| tree | d6e5cfe1b1c652c3d8c8bdb76e79a5f00cf87abf | |
| parent | 14859f0e8c10c2476f04e158550c1536e4b8dbca (diff) | |
| download | seaweedfs-c04b7b411c6eafd2c9ae15ce68a907a02541df83.tar.xz seaweedfs-c04b7b411c6eafd2c9ae15ce68a907a02541df83.zip | |
refactor: Performance and readability improvement on isDefaultPort (#6960)
| -rw-r--r-- | weed/s3api/auth_signature_v4.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/weed/s3api/auth_signature_v4.go b/weed/s3api/auth_signature_v4.go index c70027106..0ddbaa917 100644 --- a/weed/s3api/auth_signature_v4.go +++ b/weed/s3api/auth_signature_v4.go @@ -763,9 +763,14 @@ func isDefaultPort(scheme, port string) bool { return true } - lowerCaseScheme := strings.ToLower(scheme) - return (lowerCaseScheme == "http" && port == "80") || - (lowerCaseScheme == "https" && port == "443") + switch port { + case "80": + return strings.EqualFold(scheme, "http") + case "443": + return strings.EqualFold(scheme, "https") + default: + return false + } } // getSignedHeaders generate a string i.e alphabetically sorted, semicolon-separated list of lowercase request header names |
