Skip to content

Commit e1fb092

Browse files
committed
simplify identifier values (discussed in #19)
1 parent 163c043 commit e1fb092

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

OpenHardwareMonitorLib/Hardware/Identifier.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,28 @@ private static void CoerceIdentifiers(string[] identifiers)
8989
for (int i = 0; i < identifiers.Length; i++)
9090
{
9191
string s = identifiers[i];
92-
identifiers[i] = Uri.EscapeDataString(identifiers[i]);
92+
if (string.IsNullOrEmpty(s))
93+
continue;
94+
95+
var sb = new StringBuilder(s.Length);
96+
foreach (char c in s)
97+
{
98+
if (IsUnreserved(c))
99+
sb.Append(c);
100+
}
101+
identifiers[i] = sb.ToString();
93102
}
94103
}
95104

105+
private static bool IsUnreserved(char c)
106+
{
107+
return
108+
(c >= 'A' && c <= 'Z') ||
109+
(c >= 'a' && c <= 'z') ||
110+
(c >= '0' && c <= '9') ||
111+
c == '-' || c == '_';// || c == '.' || c == '~';
112+
}
113+
96114
/// <inheritdoc />
97115
public override string ToString()
98116
{

0 commit comments

Comments
 (0)