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

Most upvoted comments

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

@loynoir FYI, 1 test fails in Safari 14.1.2 (16611.3.10.1.3) on macOS 11.5

Screen Shot 2021-08-10 at 11 51 06 AM

@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.

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: