Trim phrase

This commit is contained in:
Tarrgon
2025-07-01 08:36:06 -04:00
parent 1086a9fa20
commit c003b50f8d
+2 -2
View File
@@ -14,7 +14,7 @@ function friendlyPhrase(phrase: string): string {
export function shouldAlert(ticketPhrase: TicketPhrase, ticket: Ticket): { alert: boolean, match?: string } { export function shouldAlert(ticketPhrase: TicketPhrase, ticket: Ticket): { alert: boolean, match?: string } {
if (!(ticketPhrase.phrase.startsWith('/') && ticketPhrase.phrase.endsWith('/'))) { if (!(ticketPhrase.phrase.startsWith('/') && ticketPhrase.phrase.endsWith('/'))) {
if (ticket.reason.toLowerCase().includes(ticketPhrase.phrase.toLowerCase())) { if (ticket.reason.toLowerCase().includes(ticketPhrase.phrase.toLowerCase())) {
return { alert: true, match: friendlyPhrase(ticketPhrase.phrase) }; return { alert: true, match: friendlyPhrase(ticketPhrase.phrase.trim()) };
} else { } else {
return { alert: false }; return { alert: false };
} }
@@ -25,7 +25,7 @@ export function shouldAlert(ticketPhrase: TicketPhrase, ticket: Ticket): { alert
const regexMatch = regex.exec(ticket.reason); const regexMatch = regex.exec(ticket.reason);
if (regexMatch) { if (regexMatch) {
return { alert: true, match: `${friendlyPhrase(regexMatch[0])} (RegEx match: \`${ticketPhrase.phrase}\`)` }; return { alert: true, match: `${friendlyPhrase(regexMatch[0].trim())} (RegEx match: \`${ticketPhrase.phrase}\`)` };
} else { } else {
return { alert: false }; return { alert: false };
} }