Refactor JSON detection to use Regex field
Some checks failed
MSBuild / build (push) Has been cancelled
MSBuild / publish (push) Has been cancelled

This commit is contained in:
ema
2025-07-10 07:38:21 +08:00
parent 8d66dfac54
commit 10ce29e836

View File

@@ -22,6 +22,8 @@ namespace QuickLook.Plugin.TextViewer.Detectors;
public sealed class JSONDetector : IFormatDetector
{
internal Regex Signature { get; } = new(@"""[^""]+""\s*:", RegexOptions.IgnoreCase);
public string Name => "JSON";
public string Extension => ".json";
@@ -53,6 +55,6 @@ public sealed class JSONDetector : IFormatDetector
if (end < 0 || (span[end] != '}' && span[end] != ']'))
return false;
return Regex.IsMatch(text, @"""[^""]+""\s*:");
return Signature.IsMatch(text);
}
}