Skip to content

Commit

Permalink
:handle tags with whitespace correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
findus committed Dec 3, 2024
1 parent 4e3fb4d commit b6b23c5
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions web/src/components/Navigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -462,23 +462,30 @@ async function appendOrRemoveFilter(e: Event) {
return;
}
function formatValue(value: string) {
return /\s/g.test(value.trim()) ? `"${value}"` : value;
}
function formatTag(entry: { [key: string]: string }) {
return entry.keyword.trim() + ":" + formatValue(entry.value);
}
var newQuery = query.trim();
if (
current.find(
(e) => e.keyword === newSelected.keyword && e.value === newSelected.value,
) === undefined
) {
newQuery =
newQuery + " " + newSelected.keyword.trim() + ":" + newSelected.value;
newQuery = newQuery + " " + formatTag(newSelected);
} else {
newQuery = newQuery
.replaceAll(newSelected.keyword + ":" + newSelected.value, "")
.replace(/ +/g, " ");
.replaceAll(" " + formatTag(newSelected), "")
.replaceAll(formatTag(newSelected), "");
}
await router
.push({ name: "search", query: { q: newQuery.trim() } })
.catch(() => console.warn("Duplicated navigation 3:"));
.catch(() => console.warn("Duplicated navigation"));
}
</script>

Expand Down

0 comments on commit b6b23c5

Please sign in to comment.