(endpoint string)
| 183 | } |
| 184 | |
| 185 | func parseS3RegionCode(endpoint string) string { |
| 186 | if endpoint == "" { |
| 187 | return "" |
| 188 | } |
| 189 | |
| 190 | segments := strings.Split(endpoint, ".") |
| 191 | last := len(segments) - 1 |
| 192 | if last < 0 { |
| 193 | return "" |
| 194 | } |
| 195 | |
| 196 | // If the last segment is 'cn', we adjust the index accordingly. |
| 197 | if strings.EqualFold(segments[last], "cn") { |
| 198 | last-- |
| 199 | } |
| 200 | |
| 201 | // Check that we have at least three segments before the last index |
| 202 | if last >= 2 && |
| 203 | strings.EqualFold(segments[last], "com") && |
| 204 | strings.EqualFold(segments[last-1], "amazonaws") && |
| 205 | !strings.EqualFold(segments[last-2], "s3") { |
| 206 | return segments[last-2] |
| 207 | } |
| 208 | |
| 209 | return "" |
| 210 | } |
no outgoing calls
no test coverage detected