laravue icon indicating copy to clipboard operation
laravue copied to clipboard

SyntaxError: invalid regexp group, but works fine in chrome/brave

Open commentatorboy opened this issue 5 years ago • 7 comments

Hey thank you for creating this project. I did go through all of the steps to create the project. I also did run dev and production.

The thing is that it does not work in firefox. It gives me the following error: SyntaxError: invalid regexp group in the console. The page itself is blank. Where as when I run it in chrome-based browsers (like chromium or brave) it works. I am using php artisan serve to run the it in localhost.

I am running manjaro-linux.

commentatorboy avatar Jul 22 '19 13:07 commentatorboy

Experienced the same issue on Kali Linux.

What happened: Lookbehinds aren't supported on FF. [1] [2] [3]

The issue was caused on lines 41665 - 41678, specifically 41667 begin: /(?<!\\)"/, end: /(?<!\\)"/, within /public/js/app.js.

var QUOTE_STRING = { className: 'string', begin: /(?<!\\)"/, end: /(?<!\\)"/, contains: [ hljs.BACKSLASH_ESCAPE, VAR, { className: 'variable', begin: /\$\(/, end: /\)/, contains: [hljs.BACKSLASH_ESCAPE] } ] };

I tested this by simply commenting the lines out, and the dashboard loads but when you attempt to login, it reaches a 500 internal server error.

This is the last log message on the call stack:

Illuminate \ Database \ QueryException (2002)
SQLSTATE[HY000] [2002] Connection refused (SQL: select * from `users` where `email` = [email protected] limit 1)
Previous exceptions
SQLSTATE[HY000] [2002] Connection refused (2002)

[1] https://stackoverflow.com/questions/641407/javascript-negative-lookbehind-equivalent [2] https://github.com/tc39/proposal-regexp-lookbehind [3] https://stackoverflow.com/questions/50011366/javascript-regex-negative-lookbehind-not-working-in-firefox

error-try-again avatar Aug 07 '19 02:08 error-try-again

@commentatorboy , @lordcactus I tried to reproduce on firefox with https://laravue.dev, but no error found: image. I'm using Mac and Firefox 68.0.1

I also tried with php artisan serve but didn't see too. Can I get screenshots?

tuandm avatar Aug 08 '19 15:08 tuandm

Well laravue.dev also works in my firefox. (Using 68.0.1 also)

But when I run it with php artisan serve, this comes. In firefox: image

but works in chrome: image

It might be because I ran npm audit fix, but I am not sure? Let me try without the npm audit fix. Nope still same error

commentatorboy avatar Aug 08 '19 16:08 commentatorboy

@commentatorboy Thanks for your screenshots. I just removed everything and did checkout laravue again. After npm/composer install, npm run watch, php artisan serve, my Firefox works with http://localhost:8000 (I used old database so I didn't run migration): image

tuandm avatar Aug 08 '19 17:08 tuandm

I found that it might be related to the lookbehind regex (like /g)? Like @lordcactus mentioned? https://github.com/tuandm/laravue/issues/55#issuecomment-518915215

But I am not sure?

Sources: https://stackoverflow.com/questions/49816707/firefox-invalid-regex-group http://kangax.github.io/compat-table/es2016plus/

commentatorboy avatar Aug 08 '19 18:08 commentatorboy

Tooling Versions: FF quantum 68.0.1, npm 6.9.0, composer 1.9.0, Laravel Framework 5.8.13.

I removed the cloned directory and tried again to copy-pasta the 'Getting Started' instructions from https://doc.laravue.dev/ and have had the same error. I have repeated this test at least 5 times.

As I said earlier, the regex error appears to go away when I remove the function on lines 41665 - 41678. This is a hot fix and I have no idea what side effects this might cause later.

I have been toying with the features of this webapp for a day or so and haven't found any noticeable issues with having this bit of regex commented out. There is probably a specific use case I'm missing.

error-try-again avatar Aug 09 '19 01:08 error-try-again

问题原因是js向后匹配的正则兼容性问题。node版本升级到10及以上就好了。

zkeen avatar Oct 10 '19 14:10 zkeen