From 78a84faca47bbe3cd75e0eba49296c8675f47a55 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Fri, 27 Sep 2024 15:57:16 +0200 Subject: [PATCH] regex --- src/utils/reminder.ts | 7 +++---- src/utils/time.ts | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/utils/reminder.ts b/src/utils/reminder.ts index 14e385e..72549da 100644 --- a/src/utils/reminder.ts +++ b/src/utils/reminder.ts @@ -52,14 +52,13 @@ export const splitTime = (time: string) => { [OptionReminder.Mention]: "@", }; - const lowered = time.toLowerCase(); - const trimmed = lowered.replaceAll( - RegexC(Object.values(mapping).join("|"), RegExpFlags.Global), + const trimmed = time.replaceAll( + RegexC(Object.values(mapping).join("|"), RegExpFlags.Global | RegExpFlags.Insensitive), "", ); // Depending of the last character of the string - switch (lowered.slice(-1)) { + switch (time.toLowerCase().slice(-1)) { case mapping[OptionReminder.Mention]: return { time: trimmed, option: OptionReminder.Mention }; case mapping[OptionReminder.DirectMessage]: diff --git a/src/utils/time.ts b/src/utils/time.ts index 6cd8149..33f6d8c 100644 --- a/src/utils/time.ts +++ b/src/utils/time.ts @@ -53,7 +53,7 @@ export const strToSeconds = (time: string) => { RegExpFlags.Global | RegExpFlags.Insensitive, ); - const data = Object.assign({}, regex.exec(time.toLowerCase())?.groups); + const data = Object.assign({}, regex.exec(time)?.groups); if (Object.keys(data).length === 0) { // Regex returned an invalid time