inferrinizzard / prettier-sql

[ARCHIVED] Please use https://github.com/sql-formatter-org/sql-formatter
https://github.com/sql-formatter-org/sql-formatter
MIT License
21 stars 5 forks source link

[SCRIPT] Unsupported Regex breaks the app in Safari #84

Closed yuliiakorabelska closed 2 years ago

yuliiakorabelska commented 2 years ago

Describe the bug Trying to bring up the web app in Safari results in SyntaxError: Invalid regular expression: invalid group specifier name error in Console. Works fine in Chrome. To Reproduce

  1. do npm i prettier-sql in your project
  2. start the project
  3. Open the page in Safari
  4. View Develop /Web Inspector/Console. Observe: SyntaxError: Invalid regular expression: invalid group specifier name

Expected behavior App compiles and works fine.

Additional context The regex that seems to be breaking it is/(?<=[^\s]+) (AS )?(?=[^\s]+,?$)/i in Formatter.ts Per https://caniuse.com/js-regexp-lookbehind, LookBehind is not supported in Safari

inferrinizzard commented 2 years ago

Did not consider availability of lookbehind but will see if I can find a workaround for 5.x versions, this issue will definitely be gone in 6.x

nene commented 2 years ago

This is now fixed in sql-formatter 6.0.0

yuliiakorabelska commented 2 years ago

@nene Thanks!