jargons.dev icon indicating copy to clipboard operation
jargons.dev copied to clipboard

Update `key` computation logic in `$addToRecentSearchesFn`

Open babblebey opened this issue 10 months ago • 0 comments

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 😉

babblebey avatar Apr 19 '24 10:04 babblebey