diff --git a/src/util/classes.ts b/src/util/classes.ts index 33e4af11..45b85acf 100644 --- a/src/util/classes.ts +++ b/src/util/classes.ts @@ -214,7 +214,8 @@ export function matchString(str: string, categories: Category[] | null): Categor const regexes: [Category, RegExp][] = categories .filter(c => c.rule.type == 'regex') .map(c => { - const re = RegExp(c.rule.regex, c.rule.ignore_case ? 'i' : ''); + // using 'm' flag to make `$` and `^` in rules work + const re = RegExp(c.rule.regex, (c.rule.ignore_case ? 'i' : '') + 'm'); return [c, re]; }); @@ -227,6 +228,7 @@ export function matchString(str: string, categories: Category[] | null): Categor return null; } +// this is used only in tests export function classifyEvents(events: IEvent[], categories: Category[]): IEvent[] { // Compile regexes const regexes: [Category, RegExp][] = categories diff --git a/src/util/color.ts b/src/util/color.ts index 115cad32..ed9ed28b 100644 --- a/src/util/color.ts +++ b/src/util/color.ts @@ -129,11 +129,11 @@ export function getTitleAttr(bucket: { type?: string }, e: IEvent) { export function getCategoryColorFromEvent(bucket: IBucket, e: IEvent) { if (bucket.type == 'currentwindow') { - // NOTE: this will not work/break category rules which reference `$` or `^` - return getCategoryColorFromString(e.data.app + ' ' + e.data.title); + // using linebreak and "m" regex flag to make `$` and `^` work + return getCategoryColorFromString(e.data.app + '\n' + e.data.title); } else if (bucket.type == 'web.tab.current') { - // NOTE: same as above - return getCategoryColorFromString(e.data.title + ' ' + e.data.url); + // same as above + return getCategoryColorFromString(e.data.title + '\n' + e.data.url); } else if (bucket.type == 'afkstatus') { return getColorFromString(e.data.status); } else if (bucket.type?.startsWith('app.editor')) {