Skip to content
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

chore: Added default prefix parameter for web storage #425

Merged
merged 3 commits into from
Dec 11, 2022

Conversation

CatchABus
Copy link
Contributor

This adds a default prefix for web storage, in order to avoid problems like #424

Closes #424

@codecov
Copy link

codecov bot commented Dec 10, 2022

Codecov Report

Merging #425 (a387411) into main (028e1cd) will not change coverage.
The diff coverage is 100.00%.

❗ Current head a387411 differs from pull request most recent head 90163ab. Consider uploading reports for the commit 90163ab to get more accurate results

@@            Coverage Diff            @@
##              main      #425   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           17        17           
  Lines          497       497           
  Branches       151       151           
=========================================
  Hits           497       497           
Impacted Files Coverage Δ
src/storage/web-api.ts 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@arthurfiorette
Copy link
Owner

Could you add a test to check that by default it does not conflict names? Like: expects that key X does no conflict with already present X key in the storage

@CatchABus
Copy link
Contributor Author

CatchABus commented Dec 11, 2022

Could you add a test to check that by default it does not conflict names? Like: expects that key X does no conflict with already present X key in the storage

Actually, having multiple web storages is a thing I did not consider.
Since we bother adding a default, what do you think about having dynamic default parameter for each storage initialization instead?

My thought is something like this:

let storageCounter = 0;

export function buildWebStorage(storage: Storage, prefix = `axios-cache${storageCounter++}-`) {
...
}

Consequently, even if a developer does not set one's own prefix, the plugin will take care of everything.

We could also stick to the first idea though.

@arthurfiorette
Copy link
Owner

No, haha. I'm, wanting to make a test to ensure that this works for all future versions.

I'll add it myself and approve your PR :)

@arthurfiorette arthurfiorette merged commit ee25b39 into arthurfiorette:main Dec 11, 2022
@CatchABus
Copy link
Contributor Author

No, haha. I'm, wanting to make a test to ensure that this works for all future versions.

I'll add it myself and approve your PR :)

Ah I see now. I apologize for misunderstanding.
Thank you so much for your effort to complete this PR!
Plugin has been so much helpful for our apps and I'll be waiting for v1.0 release :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[localStorage] SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
2 participants