From ac485c483b446b5ebaf1a7b0d5f6373f1585cdd1 Mon Sep 17 00:00:00 2001 From: arminius-smh Date: Tue, 3 Sep 2024 19:25:34 +0200 Subject: [PATCH] server: fix loading themes from scoped packages Scoped packages have slashes in them, that led to them being loaded at the wrong path. Encoding the name fixes this. --- server/plugins/packages/themes.ts | 2 +- server/server.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/plugins/packages/themes.ts b/server/plugins/packages/themes.ts index 0594786f..67006a4f 100644 --- a/server/plugins/packages/themes.ts +++ b/server/plugins/packages/themes.ts @@ -85,7 +85,7 @@ function makePackageThemeObject( return { displayName: module.name || moduleName, filename: path.join(modulePath, module.css), - name: moduleName, + name: encodeURIComponent(moduleName), themeColor: themeColor, }; } diff --git a/server/server.ts b/server/server.ts index ab8d2419..29f696d3 100644 --- a/server/server.ts +++ b/server/server.ts @@ -107,7 +107,7 @@ export default async function ( // handler. Remember this if you make changes to this function, serving of // local themes will not get those changes. app.get("/themes/:theme.css", (req, res) => { - const themeName = req.params.theme; + const themeName = encodeURIComponent(req.params.theme); const theme = themes.getByName(themeName); if (theme === undefined || theme.filename === undefined) {