From fd5051e35d74840e91b8a3de409dd354256befc3 Mon Sep 17 00:00:00 2001 From: Filip Borum Poulsen Date: Sat, 7 Dec 2024 15:42:19 +0100 Subject: [PATCH] Made it work --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 32046f9..e93cbfe 100644 --- a/index.js +++ b/index.js @@ -52,7 +52,7 @@ app.get('/status/:gpio', function (req, res) { const gpio = req.params.gpio; const command = `pinctrl get ${gpio}`; - const regex = /^.*\| (..) \/.*$/; + const regex = new RegExp(/.*\| (..) \/.*/); child_process.exec(command, function (error, stdout, stderr) { @@ -60,9 +60,9 @@ app.get('/status/:gpio', function (req, res) { console.log(error); return res.status(500).send('Error'); } else { - const status = stdout.toString().match(regex)[1]; + const status = regex.exec(stdout)[1]; - console.log('Status', gpio, stdout); + console.log(stdout); return res.status(200).send(status); } });