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.
This commit is contained in:
arminius-smh 2024-09-03 19:25:34 +02:00
parent 0a4adc4592
commit ac485c483b
No known key found for this signature in database
2 changed files with 2 additions and 2 deletions

View file

@ -85,7 +85,7 @@ function makePackageThemeObject(
return { return {
displayName: module.name || moduleName, displayName: module.name || moduleName,
filename: path.join(modulePath, module.css), filename: path.join(modulePath, module.css),
name: moduleName, name: encodeURIComponent(moduleName),
themeColor: themeColor, themeColor: themeColor,
}; };
} }

View file

@ -107,7 +107,7 @@ export default async function (
// handler. Remember this if you make changes to this function, serving of // handler. Remember this if you make changes to this function, serving of
// local themes will not get those changes. // local themes will not get those changes.
app.get("/themes/:theme.css", (req, res) => { app.get("/themes/:theme.css", (req, res) => {
const themeName = req.params.theme; const themeName = encodeURIComponent(req.params.theme);
const theme = themes.getByName(themeName); const theme = themes.getByName(themeName);
if (theme === undefined || theme.filename === undefined) { if (theme === undefined || theme.filename === undefined) {