indexeddbshim / indexeddbshim/IndexedDBShim
RegExp issue in non-ES6 environments
- Dominant language
- JavaScript
- Stars
- 979
- Forks
- 191
- Avg merge
- 55m
- Merged PRs (30d)
- 2
Description
The newer version of globalVars uses a revised RegExp as follows:
(/(iPad|iPhone|iPod).* os 9_/ui).test(navigator.userAgent)
The u (unicode) flag is new for ES6. This new RegExp fails to instantiate in older browsers, causing poorIndexedDbSupport not to be detected in, for example, Safari on IOS 9.
```
new RegExp("(iPad|iPhone|iPod).* os 9_", "ui")
SyntaxError: Invalid flags supplied to RegExp constructor.
(/(iPad|iPhone|iPod).* os 9_/ui).test(navigator.userAgent)
SyntaxError: Invalid flag supplied to RegExp constructor.
```
Suggested resolution is to remove the u flag to enable the RegExp to work as expected.
Contributor guide
Research direction
Start from the globalVars code that constructs the user-agent RegExp for poorIndexedDbSupport and check its behavior in a non-ES6 browser such as Safari on iOS 9. Remove the unsupported Unicode flag, then verify that the detection still matches the intended user-agent and no longer raises a syntax error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100