codebytere.github.io icon indicating copy to clipboard operation
codebytere.github.io copied to clipboard

localStorage usage is buggy

Open dsanders11 opened this issue 6 years ago • 1 comments

Cool site. Seems the usage of localStorage is buggy though. In particular, in this line:

https://github.com/codebytere/codebytere.github.io/blob/3d5854bea758dfe0266b6ffc4b77a0b03a0cb782/js/shell.js#L42

localStorage.inHistory will always evaluate to be true. That's because everything put into localStorage is coerced to a string:

The keys and the values are always strings (note that, as with objects, integer keys will be automatically converted to strings).

So this line:

https://github.com/codebytere/codebytere.github.io/blob/3d5854bea758dfe0266b6ffc4b77a0b03a0cb782/js/shell.js#L12

is actually setting inHistory to the string "false", and Boolean("false") === true.

Doesn't look like your usage of localStorage persists between page loads (everything resets) so there's no real need to use it.

dsanders11 avatar Jun 19 '19 03:06 dsanders11

oh TIL! i wrote this thing a while ago so it seems it's time for some updates 😆

i'll try to get to this at a Soon Time™️

codebytere avatar Jun 27 '19 06:06 codebytere