Skip to content

Commit

Permalink
fix: sessionStorage security error (#3246)
Browse files Browse the repository at this point in the history
  • Loading branch information
stepan662 authored Sep 11, 2023
1 parent eb529f1 commit 58479f8
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,20 @@ export type BrowserExtensionProps = {

let BrowserExtensionPlugin: () => TolgeePlugin = () => (tolgee) => tolgee;

if (typeof window !== 'undefined' && typeof sessionStorage !== 'undefined') {
const sessionStorageAvailable = () => {
if (typeof window === 'undefined') {
return false;
}
try {
return typeof sessionStorage !== 'undefined' && sessionStorage;
} catch (err) {
// eslint-disable-next-line no-console
console.error('sessionStorage not available', err);
return false;
}
};

if (sessionStorageAvailable()) {
BrowserExtensionPlugin = (): TolgeePlugin => (tolgee) => {
const handshaker = Handshaker();
const getConfig = () =>
Expand Down

0 comments on commit 58479f8

Please sign in to comment.