Skip to content

Commit 2d354ac

Browse files
committed
Fixed a bug where values in data, server variables, etc. containing start or end quotes would be trimmed
1 parent 2d13353 commit 2d354ac

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed
Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Elmah.Io.Client;
2+
using Serilog.Events;
23
using System.Collections.Generic;
34

45
#pragma warning disable IDE0130 // Namespace does not match folder structure
@@ -9,13 +10,23 @@ internal static class KeyValuePairExtensions
910
{
1011
internal static Item ToItem<TKey, TValue>(this KeyValuePair<TKey, TValue> keyValuePair)
1112
{
12-
return new Item(Trim(keyValuePair.Key?.ToString()), Trim(keyValuePair.Value?.ToString()));
13+
return new Item(RawValue(keyValuePair.Key), RawValue(keyValuePair.Value));
1314
}
1415

15-
private static string Trim(string s)
16+
private static string RawValue(object obj)
1617
{
17-
if (string.IsNullOrWhiteSpace(s)) return null;
18-
return s.TrimStart('\"').TrimEnd('\"');
18+
if (obj == null) return null;
19+
20+
// Handling of ScalarValue from Serilog
21+
if (obj is ScalarValue scalar)
22+
{
23+
return scalar.Value?.ToString();
24+
}
25+
26+
// For other types, use ToString and treat whitespace as null
27+
var result = obj.ToString();
28+
29+
return string.IsNullOrWhiteSpace(result) ? null : result;
1930
}
2031
}
2132
}

0 commit comments

Comments
 (0)