refactor: Performance and readability improvement on isDefaultPort (#6960)

This commit is contained in:
Joon Young Baik 2025-07-11 00:50:20 +12:00 committed by GitHub
parent 14859f0e8c
commit c04b7b411c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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