The current logic in the $addToRecentSearchesFn function of /lib/stores/search.js computes the key for recent searches by converting the word to lowercase and replacing spaces with hyphens. This can be improved by using the normalizeAsUrl utility function exported from lib/utils/index.js to ensure consistency and better handling of special characters.
Proposed Changes:
Update the key computation in $addToRecentSearchesFn from:
const lowercaseKey = word.toLowerCase();
const key = lowercaseKey.includes(" ") ? lowercaseKey.split(" ").join("-") : lowercaseKey;
to:
const key = normalizeAsUrl(word);
Related Files:
Additional Information:
- Nothing much, feel free to ask any question if you need more clarity on the steps to take 😉
The current logic in the
$addToRecentSearchesFnfunction of/lib/stores/search.jscomputes thekeyfor recent searches by converting the word to lowercase and replacing spaces with hyphens. This can be improved by using thenormalizeAsUrlutility function exported fromlib/utils/index.jsto ensure consistency and better handling of special characters.Proposed Changes:
Update the
keycomputation in$addToRecentSearchesFnfrom:to:
Related Files:
Additional Information: