HideAPIKey obscures an API key for logging purposes, showing only the first and last few characters. Parameters: - apiKey: The API key to hide. Returns: - string: The obscured API key.
(apiKey string)
| 179 | // Returns: |
| 180 | // - string: The obscured API key. |
| 181 | func HideAPIKey(apiKey string) string { |
| 182 | if len(apiKey) > 8 { |
| 183 | return apiKey[:4] + "..." + apiKey[len(apiKey)-4:] |
| 184 | } else if len(apiKey) > 4 { |
| 185 | return apiKey[:2] + "..." + apiKey[len(apiKey)-2:] |
| 186 | } else if len(apiKey) > 2 { |
| 187 | return apiKey[:1] + "..." + apiKey[len(apiKey)-1:] |
| 188 | } |
| 189 | return apiKey |
| 190 | } |
| 191 | |
| 192 | // maskAuthorizationHeader masks the Authorization header value while preserving the auth type prefix. |
| 193 | // Common formats: "Bearer <token>", "Basic <credentials>", "ApiKey <key>", etc. |
no outgoing calls
no test coverage detected