Skip to content

Commit 9ae9832

Browse files
Remove check for null
1 parent 0b19fb2 commit 9ae9832

File tree

1 file changed

+1
-6
lines changed
  • src/libraries/System.Web.HttpUtility/src/System/Web/Util

1 file changed

+1
-6
lines changed

src/libraries/System.Web.HttpUtility/src/System/Web/Util/HttpEncoder.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,10 @@ private static int IndexOfHtmlAttributeEncodingChars(string s) =>
125125

126126
internal static string JavaScriptStringEncode(string? value, bool addDoubleQuotes)
127127
{
128-
if (string.IsNullOrEmpty(value))
129-
{
130-
return addDoubleQuotes ? @"""""" : string.Empty;
131-
}
132-
133128
int i = value.AsSpan().IndexOfAny(s_invalidJavaScriptChars);
134129
if (i < 0)
135130
{
136-
return addDoubleQuotes ? $"\"{value}\"" : value;
131+
return addDoubleQuotes ? $"\"{value}\"" : value ?? string.Empty;
137132
}
138133

139134
return EncodeCore(value, i, addDoubleQuotes);

0 commit comments

Comments
 (0)