MCPcopy Create free account
hub / github.com/apecloud/myduckserver / parseS3RegionCode

Function parseS3RegionCode

storage/object_storage.go:185–210  ·  view source on GitHub ↗
(endpoint string)

Source from the content-addressed store, hash-verified

183}
184
185func 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}

Callers 1

parseRegionFromEndpointFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected