mirror of
https://github.com/QL-Win/QuickLook.git
synced 2026-02-01 01:08:29 +08:00
Remove UTF-8 BOM before JSON detection
Added logic to strip the UTF-8 BOM character from the start of the text before performing JSON format detection. This ensures that files with a BOM are correctly identified as JSON.
This commit is contained in:
@@ -36,6 +36,10 @@ public sealed class JSONDetector : IFormatDetector
|
||||
|
||||
var span = text.AsSpan();
|
||||
|
||||
// Remove UTF-8 BOM if present
|
||||
if (span.Length > 0 && span[0] == '\uFEFF')
|
||||
span = span.Slice(1);
|
||||
|
||||
// TrimStart
|
||||
int start = 0;
|
||||
while (start < span.Length && char.IsWhiteSpace(span[start]))
|
||||
|
||||
Reference in New Issue
Block a user