Skip to content

Commit a45e7f6

Browse files
committed
filters: escape payee suggestions
1 parent ca7a182 commit a45e7f6

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

frontend/src/journal/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { journalShow } from "../stores/journal";
55
import JournalFilters from "./JournalFilters.svelte";
66

77
/**
8-
* Escape the value to produce a valid regex.
8+
* Escape the value to produce a valid regex for the Fava filter.
99
*/
10-
function escape(value: string): string {
10+
export function escape(value: string): string {
1111
return value.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&");
1212
}
1313

frontend/src/sidebar/FilterForm.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<script lang="ts">
22
import AutocompleteInput from "../AutocompleteInput.svelte";
33
import { _ } from "../i18n";
4+
import { escape } from "../journal";
45
import { accounts, links, payees, tags, years } from "../stores";
56
import { account_filter, fql_filter, time_filter } from "../stores/filters";
67
78
$: fql_filter_suggestions = [
89
...$tags.map((tag) => `#${tag}`),
910
...$links.map((link) => `^${link}`),
10-
...$payees.map((payee) => `payee:"${payee}"`),
11+
...$payees.map((payee) => `payee:"${escape(payee)}"`),
1112
];
1213
1314
function valueExtractor(value: string, input: HTMLInputElement) {

0 commit comments

Comments
 (0)