@@ -162,10 +162,20 @@ export class SimpleDb {
162
162
// ua = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML,
163
163
// like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0';
164
164
165
+ // iOS Safari: Disable for users running iOS version < 10.
166
+ const iOSVersion = SimpleDb . getIOSVersion ( ua ) ;
167
+ const isUnsupportedIOS = 0 < iOSVersion && iOSVersion < 10 ;
168
+
169
+ // Android browser: Disable for userse running version < 4.5.
170
+ const androidVersion = SimpleDb . getAndroidVersion ( ua ) ;
171
+ const isUnsupportedAndroid = 0 < androidVersion && androidVersion < 4.5 ;
172
+
165
173
if (
166
174
ua . indexOf ( 'MSIE ' ) > 0 ||
167
175
ua . indexOf ( 'Trident/' ) > 0 ||
168
- ua . indexOf ( 'Edge/' ) > 0
176
+ ua . indexOf ( 'Edge/' ) > 0 ||
177
+ isUnsupportedIOS ||
178
+ isUnsupportedAndroid
169
179
) {
170
180
return false ;
171
181
} else {
@@ -181,6 +191,27 @@ export class SimpleDb {
181
191
return txn . store < KeyType , ValueType > ( store ) ;
182
192
}
183
193
194
+ // visible for testing
195
+ /** Parse User Agent to determine iOS version. Returns -1 if not found. */
196
+ static getIOSVersion ( ua : string ) : number {
197
+ const iOSVersionRegex = ua . match ( / i (?: p h o n e | p a d | p o d ) o s ( [ \d _ ] + ) / i) ;
198
+ const version = iOSVersionRegex ? iOSVersionRegex [ 1 ] . split ( '_' ) [ 0 ] : '-1' ;
199
+ return Number ( version ) ;
200
+ }
201
+
202
+ // visible for testing
203
+ /** Parse User Agent to determine Android version. Returns -1 if not found. */
204
+ static getAndroidVersion ( ua : string ) : number {
205
+ const androidVersionRegex = ua . match ( / A n d r o i d ( [ \d . ] + ) / i) ;
206
+ const version = androidVersionRegex
207
+ ? androidVersionRegex [ 1 ]
208
+ . split ( '.' )
209
+ . slice ( 0 , 2 )
210
+ . join ( '.' )
211
+ : '-1' ;
212
+ return Number ( version ) ;
213
+ }
214
+
184
215
constructor ( private db : IDBDatabase ) { }
185
216
186
217
runTransaction < T > (
0 commit comments