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

Don't access localStorage if it is not available #31

Merged
merged 1 commit into from
Jun 6, 2022

Conversation

Windvis
Copy link
Contributor

@Windvis Windvis commented May 13, 2022

Description

The changes introduced by #17 throw exceptions when localStorage is not available. Some browsers completely remove the localStorage key when certain settings are enabled (for example: "disable all cookies"). This adds an extra check to ensure localStorage is available before accessing it.

Related Issue

Fixes #25

Screenshots or GIFs (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Some browsers completely remove the localStorage key when certain settings are enabled (for example: "disable all cookies"). This adds an extra check to ensure localStorage is available before accessing it.
@codecov
Copy link

codecov bot commented May 13, 2022

Codecov Report

Merging #31 (879e8bc) into master (0369c0e) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master       #31   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines           76        78    +2     
  Branches        19        22    +3     
=========================================
+ Hits            76        78    +2     
Impacted Files Coverage Δ
src/lib/request.ts 100.00% <100.00%> (ø)

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@ukutaht
Copy link
Contributor

ukutaht commented Jun 6, 2022

This is now released under 0.3.6

@Windvis Windvis deleted the fix/local-storage-access-check branch June 6, 2022 09:01
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.

Error in sendEvent when localStorage is null or otherwise unavailable
2 participants