Skip to content

Commit

Permalink
Clean up localStorage after testing its availability
Browse files Browse the repository at this point in the history
  • Loading branch information
Acconut committed Dec 5, 2022
1 parent bccee72 commit 4f3bd09
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/browser/urlStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ try {

// Attempt to store and read entries from the local storage to detect Private
// Mode on Safari on iOS (see #49)
// If the key was not used before, we remove it from local storage again to
// not cause confusion where the entry came from.
const key = 'tusSupport'
localStorage.setItem(key, localStorage.getItem(key))

This comment has been minimized.

Copy link
@YEENSLy

YEENSLy Dec 16, 2022

offline

const originalValue = localStorage.getItem(key)
localStorage.setItem(key, originalValue)
if (originalValue === null) localStorage.removeItem(key)
} catch (e) {
// If we try to access localStorage inside a sandboxed iframe, a SecurityError
// is thrown. When in private mode on iOS Safari, a QuotaExceededError is
Expand Down

0 comments on commit 4f3bd09

Please sign in to comment.