Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite condition query matching regex breaks in older browsers #26106

Closed
jamsinclair opened this issue Jun 15, 2021 · 3 comments
Closed

Rewrite condition query matching regex breaks in older browsers #26106

jamsinclair opened this issue Jun 15, 2021 · 3 comments
Labels
bug Issue was opened via the bug report template.

Comments

@jamsinclair
Copy link
Contributor

jamsinclair commented Jun 15, 2021

What version of Next.js are you using?

10.2.3

What version of Node.js are you using?

14.16.0

What browser are you using?

Safari <=10, IE 11, Edge 14-18

What operating system are you using?

macOS, Windows

How are you deploying your application?

next start

Describe the Bug

When using a rewrite has condition regex errors are thrown in older browsers that Next.js supports.

Error:

SyntaxError: Invalid regular expression: unrecognized character after (?

Stack:

[native code] in RegExp
/_next/static/chunks/polyfills-283031c735651d1762e0.js in fi at line 1:37280

/_next/static/chunks/f6078781a05fe1bcb0902d23dbbb2662c8d200b3.7b6fc0bd183f5b80ad0c.js at line 1:5376

[native code] in every
/_next/static/chunks/f6078781a05fe1bcb0902d23dbbb2662c8d200b3.7b6fc0bd183f5b80ad0c.js in matchHas at line 1:5059

Example condition:

async rewrites() {
    return [
        {
            source: '/current-host',
            has: [
                {
                    type: 'host',
                    value: '(?<host>.*)',
                },
            ], 
            destination: '/show-host/:host',
        }
    ]
}

Expected Behavior

Regex used in paths and rewrite conditions should be supported in older browsers that Next.js supports.

To Reproduce

  1. Visit https://next-has-condition-regex-bug.vercel.app/current-host
  2. In older browsers, like IE11, Safari 10.1, observe regex error Invalid regular expression: unrecognized character after (?
  3. Otherwise, text should say: Current host is next-has-condition-regex-bug.vercel.app

App Source Code: https://github.com/jamsinclair/next-has-condition-regex-bug

@jamsinclair jamsinclair added the bug Issue was opened via the bug report template. label Jun 15, 2021
@jamsinclair
Copy link
Contributor Author

We do polyfill some regex features with core-js:

import 'core-js/features/regexp'

Unfortunately, lookbehind regex has yet to be polyfilled zloirock/core-js#876.

@jankaifer
Copy link
Contributor

We don't support these browsers anymore.

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

2 participants