sindresorhus / got

🌐 Human-friendly and powerful HTTP request library for Node.js
MIT License
14.3k stars 935 forks source link

Lookback regex breaks firefox when the package is used as a dependency in meteor #1447

Closed bogdanrn closed 4 years ago

bogdanrn commented 4 years ago

Describe the bug

When the got package is being used as part of a dependency in a meteor project, the regex used here:

https://github.com/sindresorhus/got/blob/master/source/core/index.ts#L2313

Makes the web-app unable to load in firefox (chrome works fine). I guess the same bug would happen if webpack is used as well.

Actual behavior

Firefox throws error in console: SyntaxError: invalid regexp group. Breaks the whole script.

Expected behavior

No firefox error when a regex check is done.

Code to reproduce

Run the following line in firefox console

 /(<socketPath>.+?):(?<path>.+)/.exec(`'test'`);

Checklist

Giotino commented 4 years ago

This would be an easy fix, but I think you shouldn't use Got on non-Node.JS platforms (like a Browser).

From the documentation:

For browser usage, we recommend Ky by the same people.

sindresorhus commented 4 years ago

I believe this was fixed in the latest Firefox version where they started using the same regex code as Chrome. We don't intend to work around this as the main target for Got is Node.js.