Skip to content

Commit

Permalink
Remove check for null
Browse files Browse the repository at this point in the history
  • Loading branch information
TrayanZapryanov committed Jun 4, 2024
1 parent 583bab4 commit 5d498a4
Showing 1 changed file with 1 addition and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,10 @@ private static int IndexOfHtmlAttributeEncodingChars(string s) =>

internal static string JavaScriptStringEncode(string? value, bool addDoubleQuotes)
{
if (string.IsNullOrEmpty(value))
{
return addDoubleQuotes ? @"""""" : string.Empty;
}

int i = value.AsSpan().IndexOfAny(s_invalidJavaScriptChars);
if (i < 0)
{
return addDoubleQuotes ? $"\"{value}\"" : value;
return addDoubleQuotes ? $"\"{value}\"" : value ?? string.Empty;
}

return EncodeCore(value, i, addDoubleQuotes);
Expand Down

0 comments on commit 5d498a4

Please sign in to comment.