jargons.dev
jargons.dev copied to clipboard
Update `key` computation logic in `$addToRecentSearchesFn`
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:
- https://github.com/babblebey/jargons.dev/blob/main/src/lib/stores/search.js
Additional Information:
- Nothing much, feel free to ask any question if you need more clarity on the steps to take 😉