-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: SafeLocalStorage handle undefined value #3478
base: main
Are you sure you want to change the base?
Conversation
|
@combab0 is attempting to deploy a commit to the Reown Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@combab0 can you add a test pls?
@@ -37,7 +37,7 @@ export const SafeLocalStorage = { | |||
key: Key, | |||
value: SafeLocalStorageItems[Key] | |||
): void { | |||
if (isSafe()) { | |||
if (isSafe() && value !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (isSafe() && value !== undefined) { | |
if (value && isSafe()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not happen as they are strings but this might result in a weird behavior if value
is false
Description
If localStorage.setItem('item', undefined) is executed, the string 'undefined' is stored as the value for 'item', which is a bug. SafeLocalStorage should avoid setting values in localStorage when the value is undefined to ensure safer behavior.
This patch also resolves the following currently occurring error:
Type of change
Associated Issues
None
Showcase (Optional)
None
Checklist