Skip to content

Commit

Permalink
Format JSON message (#57)
Browse files Browse the repository at this point in the history
* Format JSON message

* Catch JsonException when formatting

* Try formatting json if no content type is set

* TryFormatBody refactor
  • Loading branch information
anweihe authored Apr 12, 2024
1 parent c5ca85a commit 7d63cbf
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Ui/Website/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ public static string TryFormatBody(this string value, string? contentType)
{
if (contentType != null)
{
if (contentType.Contains("json", StringComparison.InvariantCultureIgnoreCase))
{
return TryFormatJson(value);
}
return contentType.Contains("json", StringComparison.InvariantCultureIgnoreCase)
? TryFormatJson(value)
: value;
}

return value;
return TryFormatJson(value);
}

public static string SplitAndGetLastSection(this string value, char split)
Expand Down

0 comments on commit 7d63cbf

Please sign in to comment.