normalize-url: SyntaxError: Invalid regular expression: invalid group specifier name
Hey, I’m getting this error here on iOS and macOS Safari:
SyntaxError: Invalid regular expression: invalid group specifier name
It comes from here:
// Remove duplicate slashes if not preceded by a protocol
if (urlObj.pathname) {
urlObj.pathname = urlObj.pathname.replace(/(?<!https?:)\/{2,}/g, '/');
}
My code: https://github.com/muuvmuuv/portfolio/blob/master/src/elements/Link.jsx Live error: https://portfolio-git-development.muuvmuuv.now.sh/
I am using version 5.x
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 8
- Comments: 36 (7 by maintainers)
Commits related to this issue
- fix(dashboard): fix normalize-url to version 4 The latest version doesn't work on Safari and Firefox. See here: https://github.com/sindresorhus/normalize-url/issues/105 — committed to garden-io/garden by eysi09 4 years ago
- fix(dashboard): fix normalize-url to version 4 The latest version doesn't work on Safari and Firefox. See here: https://github.com/sindresorhus/normalize-url/issues/105 — committed to garden-io/garden by eysi09 4 years ago
- fix(dashboard): fix normalize-url to version 4 The latest version doesn't work on Safari and Firefox. See here: https://github.com/sindresorhus/normalize-url/issues/105 — committed to garden-io/garden by eysi09 4 years ago
- fix(dashboard): fix normalize-url to version 4 The latest version doesn't work on Safari and Firefox. See here: https://github.com/sindresorhus/normalize-url/issues/105 — committed to garden-io/garden by eysi09 4 years ago
- Add `useJsRegexpLookbehind` option (#105) — committed to loynoir/normalize-url by loynoir 3 years ago
- Add `preferJsRegexpLookbehind` option (#105) — committed to loynoir/normalize-url by loynoir 3 years ago
- changes in test workflow 1. [test] Move `ava` to `mocha+chai` to test in real browser. (#105) (#140) (#142) 2. [test] seprate non special-protocol-schemes(#147) 3. [doc] Update readme — committed to loynoir/normalize-url by loynoir 3 years ago
Hey, I’m coming from Gatsby, thanks a lot for this issue. As mentioned above, it’s a critical issue.
And this has been open for a while. Any Idea why there hasn’t been any progress on something that seems like a simple syntax error?
Thanks
Fixed in https://github.com/sindresorhus/normalize-url/releases/tag/v7.0.1
See here https://github.com/sindresorhus/normalize-url#install
@loynoir FYI, 1 test fails in Safari 14.1.2 (16611.3.10.1.3) on macOS 11.5
@gregdingle Not sure if you meant to reference me, but I don’t see how to avoid the negative lookbehinds. I’m certainly no regex expert so I can’t say it’s impossible. I don’t use this in a browser either, so I’m not motivated to try to work around an annoying browser limitation.
Alternative would be to use this package. Just as long as browsers are not fully support it.
Sandbox: https://codesandbox.io/s/normalize-url-issues-105-sex88?file=/src/index.js
It’s critical issue! Page that uses normalize-url version 5 can’t be opened in iOS nor macOS!
Note that this also impacts Gatsby projects in “develop” mode on firefox 74 (current) - negative lookbehinds work for building a site, but when developing it also rebuilds pages in the browser.
Oh… what a shame. Thought it says >4 not =4 but okay will fix the version tho.
Can we leave this open until browsers will add support for negative lookbehinds?
Browser support: