Closed loynoir closed 3 years ago
I'm unfortunately not interested in an option like this.
Hi, @sindresorhus I remove that in option, what do you think if I change that to detect-fallback?
I think at least one line should be changed https://github.com/sindresorhus/normalize-url/blob/3fb24bb03e340162b2e81d6145de8e4e5b3d6262/index.js#L124
As I don't have an environment lack of js-regexp-lookbehind, I use unbalance /(/
for damonstration
In node.js is OK, ok fn is not held down by SyntaxError.
> console.log('ok fn'); try { /(/ } catch(e) {console.log('err fn') }
ok fn
err fn
But in browser, ok fn is not even ran, which is held down by SyntaxError.
var s1=document.createElement('script')
s1.innerText=`console.log('ok fn'); try { /(/ } catch(e) {console.log('err fn') }`
document.head.appendChild(s1)
// Uncaught SyntaxError: unterminated parenthetical
- Expected
```js
var s2=document.createElement('script')
s2.innerText=`console.log('ok fn'); try { new RegExp('(') } catch(e) {console.log('err fn') }`
document.head.appendChild(s2)
// ok fn
// err fn
As SyntaxError can not be try-catch, use new RegExp to avoid js parser error.