@@ -4,7 +4,7 @@ import { EventsCacheInMemory } from '../inMemory/EventsCacheInMemory';
4
4
import { IStorageFactoryParams , IStorageSync , IStorageSyncFactory , StorageAdapter } from '../types' ;
5
5
import { validatePrefix } from '../KeyBuilder' ;
6
6
import { KeyBuilderCS , myLargeSegmentsKeyBuilder } from '../KeyBuilderCS' ;
7
- import { isLocalStorageAvailable , isValidStorageWrapper } from '../../utils/env/isLocalStorageAvailable' ;
7
+ import { isLocalStorageAvailable , isValidStorageWrapper , isWebStorage } from '../../utils/env/isLocalStorageAvailable' ;
8
8
import { SplitsCacheInLocal } from './SplitsCacheInLocal' ;
9
9
import { RBSegmentsCacheInLocal } from './RBSegmentsCacheInLocal' ;
10
10
import { MySegmentsCacheInLocal } from './MySegmentsCacheInLocal' ;
@@ -66,7 +66,11 @@ export function storageAdapter(log: ILogger, prefix: string, wrapper: SplitIO.St
66
66
67
67
function validateStorage ( log : ILogger , prefix : string , wrapper ?: SplitIO . StorageWrapper ) : StorageAdapter | undefined {
68
68
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
+ }
70
74
log . warn ( LOG_PREFIX + 'Invalid storage provided. Falling back to LocalStorage API' ) ;
71
75
}
72
76
0 commit comments