-
-
Notifications
You must be signed in to change notification settings - Fork 117
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
GetItemAsync<string> fails if value doesn't contain quotes #57
Comments
Thanks for reporting this @tomidix. I can see what the problem is, all values are serialised to a string before being saved to local storage, even strings 🤦♂️. In your example, when trying to read values out the library tries to deserialise them as well, again even if they're strings 🤦♂️, which is why you're seeing the problem, if the string hasn't been serialised on the way in it thrown when trying to deserialise on the way out. Does that make sense? I'll get a fix coded up for this. Note to self: Need to be careful as this will break some peoples data. Need to have some kind of migration plan. |
I didn't look at the code of the library but the fix seems to be obvious to me and I think it should be backward compatible. |
I agree, @tomidix and that's pretty much exactly what I've done. I've fixed the set code so that a string will no longer be serialised, it will just be persisted as-is. |
Describe the bug
localStorage.GetItemAsync<**string**>("test")
fails if localStorage record looks like this:test|demoValue
If it is test|"demoValue" then everything works fine.
To Reproduce
Steps to reproduce the behavior:
Just add a new localStorage value manually in browser and try to read it with library. Try changing the value to be with and without quotes.
Expected behavior
Read the value without quotes as string as it's not expected to read our own localStorage values. Sometimes other library writes the values and we should read them.
Hosting Model (is this issue happening with a certain hosting model?):
Additional context
Using latest library package, 2.1.1
The text was updated successfully, but these errors were encountered: