From 9ec4fb8b5417699eb0d69bccdb24bfbcf7917dac Mon Sep 17 00:00:00 2001 From: DietrichGebert Date: Thu, 2 Jul 2026 00:25:27 +0200 Subject: [PATCH] fix: strip UTF-8 BOM before parsing config.json (#478) getDefaultMode() parsed the config with JSON.parse and no BOM strip, so a config.json saved with a UTF-8 BOM (common on Windows) failed to parse and the user's defaultMode was silently ignored. Strip the BOM first, matching the existing /^\uFEFF/ pattern in ponytail-activate.js, check-versions.js, and ponytail-mode-tracker.js. Closes #375 Co-authored-by: nanaubusiness <195150264+nanaubusiness@users.noreply.github.com> --- hooks/ponytail-config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hooks/ponytail-config.js b/hooks/ponytail-config.js index 86677b1..1838b87 100644 --- a/hooks/ponytail-config.js +++ b/hooks/ponytail-config.js @@ -83,7 +83,8 @@ function getDefaultMode() { // 2. Config file try { const configPath = getConfigPath(); - const config = JSON.parse(fs.readFileSync(configPath, 'utf8')); + // Strip UTF-8 BOM (common on Windows-saved files) so JSON.parse doesn't choke + const config = JSON.parse(fs.readFileSync(configPath, 'utf8').replace(/^\uFEFF/, '')); if (config.defaultMode && VALID_MODES.includes(config.defaultMode.toLowerCase())) { return config.defaultMode.toLowerCase(); }