From 36da8a112df7ec32c396cec271f2114c8ee29ae2 Mon Sep 17 00:00:00 2001 From: UNITRONIX <36471318+UNITRONIX@users.noreply.github.com> Date: Sat, 19 Sep 2026 11:04:38 +0200 Subject: [PATCH] fix(update): preserve explicit config file extensions Prevent the console repair scan from turning JSON requires into .json.js download paths. Thanks: INSOLVE (Honorary); Marco Jakobs (@jacotec); MyNameisStitch (@MyNameisStitch); Redspin (@playerumpknow) --- web-nodejs/lib/consoleDeployGraph.js | 7 +++++++ web-nodejs/tests/updateService.consoleSync.test.js | 2 ++ 2 files changed, 9 insertions(+) diff --git a/web-nodejs/lib/consoleDeployGraph.js b/web-nodejs/lib/consoleDeployGraph.js index ed673dde..c7841bb6 100644 --- a/web-nodejs/lib/consoleDeployGraph.js +++ b/web-nodejs/lib/consoleDeployGraph.js @@ -36,6 +36,13 @@ function createConsoleDeployGraph(rootDir) { return path.posix.join(resolved, 'index.js'); } + // Preserve explicit non-JavaScript extensions such as .json. + // Appending .js here turns require('./config/theme.json') into + // the invalid repair path config/theme.json.js. + if (/\.(?:json|ya?ml|css|html?|txt|svg|xml|toml|ini)$/i.test(resolved)) { + return resolved; + } + if (!resolved.endsWith('.js')) resolved += '.js'; const absJs = path.join(rootDir, resolved); if (!fs.existsSync(absJs)) { diff --git a/web-nodejs/tests/updateService.consoleSync.test.js b/web-nodejs/tests/updateService.consoleSync.test.js index b18b4b1f..35ae254a 100644 --- a/web-nodejs/tests/updateService.consoleSync.test.js +++ b/web-nodejs/tests/updateService.consoleSync.test.js @@ -27,6 +27,8 @@ describe('updateService console sync helpers', () => { const graph = createConsoleDeployGraph(require('path').join(__dirname, '..')); expect(graph.resolveConsoleRequire('routes/auth.routes.js', '../services/serverAttestation')) .toBe('services/serverAttestation.js'); + expect(graph.resolveConsoleRequire('services/brandingService.js', '../config/theme-palettes.json')) + .toBe('config/theme-palettes.json'); expect(graph.resolveConsoleRequire('routes/index.js', './devices.routes')) .toBe('routes/devices.routes.js'); expect(graph.resolveConsoleRequire('server.js', './routes'))