Handle whitespace and add StringComparison in validation

This commit is contained in:
Thorsten Sommer 2025-06-11 10:13:26 +02:00
parent 7c4ddf1164
commit 0d84feb12a
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -6,7 +6,7 @@ public static class StringExtensions
{ {
const string OPEN_TAG = "<think>"; const string OPEN_TAG = "<think>";
const string CLOSE_TAG = "</think>"; const string CLOSE_TAG = "</think>";
if (string.IsNullOrEmpty(input) || !input.StartsWith(OPEN_TAG)) if (string.IsNullOrWhiteSpace(input) || !input.StartsWith(OPEN_TAG, StringComparison.Ordinal))
return input; return input;
var endIndex = input.IndexOf(CLOSE_TAG, StringComparison.Ordinal); var endIndex = input.IndexOf(CLOSE_TAG, StringComparison.Ordinal);