regex
All checks were successful
PR Check / lint-and-format (pull_request) Successful in 18s

This commit is contained in:
Mylloon 2024-09-27 15:57:16 +02:00
parent b20365db13
commit 78a84faca4
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 4 additions and 5 deletions

View file

@ -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]:

View file

@ -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