From 2bcd133edf3cf3be15934a19052074e5dee04fcb Mon Sep 17 00:00:00 2001 From: Vrganj Date: Thu, 14 Jan 2021 20:25:45 +0100 Subject: [PATCH] Fix validation, versions --- api/src/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/src/index.js b/api/src/index.js index 1bb789f..76c4e50 100644 --- a/api/src/index.js +++ b/api/src/index.js @@ -12,7 +12,7 @@ const versions = execFileSync(__dirname + '/../../lxc/versions') .filter(section => section.length >= 2); function getVersion(language) { - return versions.find(section => section[0] === language?.name); + return versions.find(section => section[0] === language?.name)?.slice(1).join('\n'); } for (const language of languages) { @@ -35,12 +35,12 @@ app.post('/execute', (req, res) => { code: 'unsupported_language', message: `${body.language} is not supported by Piston`, }); - } else if (!(body.source instanceof string)) { + } else if (typeof body.source !== 'string') { return res.status(400).json({ code: 'missing_source', message: 'source field is invalid', }); - } else if (body.args && !(body.args instanceof Array)) { + } else if (body.args && Array.isArray(body.args)) { return res.status(400).json({ code: 'invalid_args', message: 'args field is not an array',