Skip to content

Commit c253b82

Browse files
committed
Refactor parts initialization inside try block
Moved the initialization of the `parts` variable, which splits the `_idToken` string, inside the `try` block. Removed the previous check for exactly three elements in the `parts` array and the default return value if the check failed.
1 parent dffc59e commit c253b82

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/KubernetesClient/Authentication/OidcTokenProvider.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,9 @@ public async Task<AuthenticationHeaderValue> GetAuthenticationHeaderAsync(Cancel
3737

3838
private DateTimeOffset GetExpiryFromToken()
3939
{
40-
var parts = _idToken.Split('.');
41-
if (parts.Length != 3)
42-
{
43-
return default;
44-
}
45-
4640
try
4741
{
42+
var parts = _idToken.Split('.');
4843
var payload = parts[1];
4944
var jsonBytes = Base64UrlDecode(payload);
5045
var json = Encoding.UTF8.GetString(jsonBytes);

0 commit comments

Comments
 (0)