Updating the regex to correctly find within the filter keys.

This commit is contained in:
mike12345567 2024-06-21 17:51:02 +01:00
parent 28d0d627ce
commit 337584f5b2
1 changed files with 1 additions and 3 deletions

View File

@ -29,10 +29,8 @@ export function updateFilterKeys(
filters: SearchFilters, filters: SearchFilters,
updates: { original: string; updated: string }[] updates: { original: string; updated: string }[]
): SearchFilters { ): SearchFilters {
// sort the updates by length first - this is necessary to avoid replacing sub-strings
updates = updates.sort((a, b) => b.original.length - a.original.length)
const makeFilterKeyRegex = (str: string) => const makeFilterKeyRegex = (str: string) =>
new RegExp(`^${str}.|:${str}.`, "g") new RegExp(`^${str}\\.|:${str}\\.`)
for (let filter of Object.values(filters)) { for (let filter of Object.values(filters)) {
if (typeof filter !== "object") { if (typeof filter !== "object") {
continue continue