Skip to content

Commit 7d000e1

Browse files
committed
extract cache key separator
1 parent c74ed92 commit 7d000e1

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/libs/SearchQueryUtils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,10 @@ function getRawFilterListFromQuery(rawQuery: SearchQueryString) {
460460
// with identical query strings, each running the full parser from scratch.
461461
const buildSearchQueryJSONCache = new Map<string, SearchQueryJSON | undefined>();
462462
const BUILD_SEARCH_QUERY_JSON_CACHE_MAX_SIZE = 50;
463+
const BUILD_SEARCH_QUERY_JSON_CACHE_KEY_SEPARATOR = '\x00'; // Null byte prevents collisions if query/rawQuery contain arbitrary strings
463464

464465
function buildSearchQueryJSON(query: SearchQueryString, rawQuery?: SearchQueryString) {
465-
const cacheKey = rawQuery ? `${query}|||${rawQuery}` : query;
466+
const cacheKey = rawQuery ? `${query}${BUILD_SEARCH_QUERY_JSON_CACHE_KEY_SEPARATOR}${rawQuery}` : query;
466467
if (buildSearchQueryJSONCache.has(cacheKey)) {
467468
return buildSearchQueryJSONCache.get(cacheKey);
468469
}

0 commit comments

Comments
 (0)