From cafa2658083c275e23dea3f95e8eb8aefc43e218 Mon Sep 17 00:00:00 2001 From: dbauszus-glx Date: Fri, 27 Oct 2023 16:54:04 +0100 Subject: [PATCH] regex capture groups --- mod/view.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mod/view.js b/mod/view.js index e89df4e23..c4ab3ce9f 100644 --- a/mod/view.js +++ b/mod/view.js @@ -67,11 +67,11 @@ module.exports = async (req, res) => { const template = await languageTemplates(params) - const view = template.replace(/[{]{2}([A-Za-z][A-Za-z0-9]*)[}]{2}/g, matched => { + const view = template.replace(/{{2}([A-Za-z][A-Za-z0-9]*)}{2}/g, matched => { - // regex matches {{ or }} - return params[matched.replace(/[{]{2}|[}]{2}/g, '')] || ''; - }); + // regex matches {{ or }} + return params[matched.replace(/(^{{)|(}}$)/g, '')] || '' + }); res.send(view); } \ No newline at end of file