Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RegExp issue in non-ES6 environments #356

Open
radicalapps opened this issue Oct 22, 2020 · 1 comment
Open

RegExp issue in non-ES6 environments #356

radicalapps opened this issue Oct 22, 2020 · 1 comment

Comments

@radicalapps
Copy link

radicalapps commented Oct 22, 2020

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.

@brettz9
Copy link
Collaborator

brettz9 commented Oct 22, 2020

I'd be open to a PR . Note that there are also new RegExp calls with the u flag so any PR should handle them as well.

I would have preferred to use https://babeljs.io/docs/en/babel-plugin-transform-unicode-regex and a Unicode-aware RegExp constructor polyfill, but:

  1. It might add significant bloat
  2. core-js at least doesn't seem to have such a polyfill anyways

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants