From 711890f5aef01391ac4b4969ced893df7a8827fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Thu, 19 Sep 2024 22:06:53 +0200 Subject: [PATCH 1/2] add word boundary check to highlighting regex --- server/util/utils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/util/utils.js b/server/util/utils.js index 856aed3..548774c 100644 --- a/server/util/utils.js +++ b/server/util/utils.js @@ -57,11 +57,11 @@ const checkHighlightTeacher = ({ description, id, value, location }) => { const getColor = (value, location, description, id, options = {}) => { if (options.highlightTeacher && checkHighlightTeacher({ description, id, value, location })) { return '#676767' - } else if (value.includes('CM') || value.toUpperCase().includes('AMPHI') || location.toUpperCase().includes('AMPHI')) { + } else if (/\bCM\b/.test(value) || value.toUpperCase().includes('AMPHI') || location.toUpperCase().includes('AMPHI')) { return options.customColor?.amphi || '#efd6d8' - } else if (value.includes('TP') || value.includes('TDi') || value.trim().match(/\sG\d\.\d$/)) { + } else if (/\bTP\b/.test(value) || value.includes('TDi') || value.trim().match(/\sG\d\.\d$/)) { return options.customColor?.tp || '#bbe0ff' - } else if ((value.includes('TD') || location.includes('V-B') || value.trim().match(/\sG\d$/)) && !/^S\d\.\d\d/.test(value) && !/contr[ôo]le/i.test(value)) { + } else if ((/\bTD\b/.test(value) || location.includes('V-B') || value.trim().match(/\sG\d$/)) && !/^S\d\.\d\d/.test(value) && !/contr[ôo]le/i.test(value)) { return options.customColor?.td || '#d4fbcc' } else { return options.customColor?.other || '#EDDD6E' From 2d12c0061aa587f7acb2b0b9eca03708f804e674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Thu, 19 Sep 2024 22:43:18 +0200 Subject: [PATCH 2/2] add TPi case to the highlighting regex --- server/util/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/util/utils.js b/server/util/utils.js index 548774c..3508c36 100644 --- a/server/util/utils.js +++ b/server/util/utils.js @@ -59,7 +59,7 @@ const getColor = (value, location, description, id, options = {}) => { return '#676767' } else if (/\bCM\b/.test(value) || value.toUpperCase().includes('AMPHI') || location.toUpperCase().includes('AMPHI')) { return options.customColor?.amphi || '#efd6d8' - } else if (/\bTP\b/.test(value) || value.includes('TDi') || value.trim().match(/\sG\d\.\d$/)) { + } else if (/\bTP\b/.test(value) || value.includes('TPi') || value.includes('TDi') || value.trim().match(/\sG\d\.\d$/)) { return options.customColor?.tp || '#bbe0ff' } else if ((/\bTD\b/.test(value) || location.includes('V-B') || value.trim().match(/\sG\d$/)) && !/^S\d\.\d\d/.test(value) && !/contr[ôo]le/i.test(value)) { return options.customColor?.td || '#d4fbcc'