Skip to content

Commit 8d43284

Browse files
committed
Refactor claim parsing to use tuple
1 parent 36d299e commit 8d43284

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

dev-proxy/ProxyHost.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,18 +389,18 @@ public RootCommand GetRootCommand(ILogger logger)
389389
var claims = new Dictionary<string, string>();
390390
foreach (var token in result.Tokens)
391391
{
392-
var claim = token.Value;
393-
var parts = claim.Split(':');
394-
var isValidClaim = parts.Length == 2 && !string.IsNullOrWhiteSpace(parts[0]) && !string.IsNullOrWhiteSpace(parts[1]);
395-
if (!isValidClaim)
392+
var claim = token.Value.Split(":");
393+
var (key, value) = (claim[0], claim[1]);
394+
395+
if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value))
396396
{
397397
result.ErrorMessage = $"Invalid claim format: '{claim}'. Expected format is name:value.";
398398
return claims ?? [];
399399
}
400400

401401
try
402402
{
403-
claims.Add(parts[0], parts[1]);
403+
claims.Add(key, value);
404404
}
405405
catch (Exception ex)
406406
{

0 commit comments

Comments
 (0)