This commit is contained in:
parent
b20365db13
commit
78a84faca4
2 changed files with 4 additions and 5 deletions
|
@ -52,14 +52,13 @@ export const splitTime = (time: string) => {
|
||||||
[OptionReminder.Mention]: "@",
|
[OptionReminder.Mention]: "@",
|
||||||
};
|
};
|
||||||
|
|
||||||
const lowered = time.toLowerCase();
|
const trimmed = time.replaceAll(
|
||||||
const trimmed = lowered.replaceAll(
|
RegexC(Object.values(mapping).join("|"), RegExpFlags.Global | RegExpFlags.Insensitive),
|
||||||
RegexC(Object.values(mapping).join("|"), RegExpFlags.Global),
|
|
||||||
"",
|
"",
|
||||||
);
|
);
|
||||||
|
|
||||||
// Depending of the last character of the string
|
// Depending of the last character of the string
|
||||||
switch (lowered.slice(-1)) {
|
switch (time.toLowerCase().slice(-1)) {
|
||||||
case mapping[OptionReminder.Mention]:
|
case mapping[OptionReminder.Mention]:
|
||||||
return { time: trimmed, option: OptionReminder.Mention };
|
return { time: trimmed, option: OptionReminder.Mention };
|
||||||
case mapping[OptionReminder.DirectMessage]:
|
case mapping[OptionReminder.DirectMessage]:
|
||||||
|
|
|
@ -53,7 +53,7 @@ export const strToSeconds = (time: string) => {
|
||||||
RegExpFlags.Global | RegExpFlags.Insensitive,
|
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) {
|
if (Object.keys(data).length === 0) {
|
||||||
// Regex returned an invalid time
|
// Regex returned an invalid time
|
||||||
|
|
Loading…
Reference in a new issue