@@ -4,7 +4,7 @@ import { EventsCacheInMemory } from '../inMemory/EventsCacheInMemory';
44import { IStorageFactoryParams , IStorageSync , IStorageSyncFactory , StorageAdapter } from '../types' ;
55import { validatePrefix } from '../KeyBuilder' ;
66import { KeyBuilderCS , myLargeSegmentsKeyBuilder } from '../KeyBuilderCS' ;
7- import { isLocalStorageAvailable , isValidStorageWrapper } from '../../utils/env/isLocalStorageAvailable' ;
7+ import { isLocalStorageAvailable , isValidStorageWrapper , isWebStorage } from '../../utils/env/isLocalStorageAvailable' ;
88import { SplitsCacheInLocal } from './SplitsCacheInLocal' ;
99import { RBSegmentsCacheInLocal } from './RBSegmentsCacheInLocal' ;
1010import { MySegmentsCacheInLocal } from './MySegmentsCacheInLocal' ;
@@ -66,7 +66,11 @@ export function storageAdapter(log: ILogger, prefix: string, wrapper: SplitIO.St
6666
6767function validateStorage ( log : ILogger , prefix : string , wrapper ?: SplitIO . StorageWrapper ) : StorageAdapter | undefined {
6868 if ( wrapper ) {
69- if ( isValidStorageWrapper ( wrapper ) ) return storageAdapter ( log , prefix , wrapper ) ;
69+ if ( isValidStorageWrapper ( wrapper ) ) {
70+ return isWebStorage ( wrapper ) ?
71+ wrapper as StorageAdapter : // localStorage and sessionStorage don't need adapter
72+ storageAdapter ( log , prefix , wrapper ) ;
73+ }
7074 log . warn ( LOG_PREFIX + 'Invalid storage provided. Falling back to LocalStorage API' ) ;
7175 }
7276
0 commit comments