fix: try to fix some codeql errors

Signed-off-by: Andrew Calcutt <acalcutt@techidiots.net>
This commit is contained in:
Andrew Calcutt 2024-04-21 00:36:00 -04:00 committed by acalcutt
parent 24a70276c5
commit b461396bbd

View file

@ -85,11 +85,22 @@ export const serve_style = {
spriteScale = as;
}
}
const filename = `${spritePath + spriteScale}.${format}`;
if (format !== 'png' && format !== 'json') {
if (!spriteScale) {
return res.sendStatus(400);
} else {
}
let spriteFormat;
const allowedFormats = ['png', 'json']
for (const af of allowedFormats) {
if (af === format) {
spriteFormat = af;
}
}
if (!spriteFormat) {
return res.sendStatus(400);
}
const filename = `${spritePath + spriteScale}.${spriteFormat}`;
// eslint-disable-next-line security/detect-non-literal-fs-filename
return fs.readFile(filename, (err, data) => {
if (err) {
@ -102,7 +113,6 @@ export const serve_style = {
return res.send(data);
}
});
}
},
);