Skip to content

Express 5: Route wildcard "(.*)" throw new TypeError in path-to-regexp #6468

Description

@infuzz

Environment information

Version:

json
"dependencies": {
  "express": "^5.1.0"
}

Platform:
Linux vm188 5.15.143-1-pve #1 SMP PVE 5.15.143-1 (2024-02-08T18:12Z) x86_64 GNU/Linux

Node.js version:
v23.11.0

Any other relevant information:
path-to-regexp (included in Express 5)
Reproducible in minimal test case

What steps will reproduce the bug?

When using a wildcard route (.*) in Express 5, the server crashes with:

const express = require('express');
const app = express();
app.get('(.*)', (req, res) => res.send('Wildcard route'));
app.listen(3000);

Console Error is:

/srv/nodejs/express5-wildcard-test/node_modules/path-to-regexp/dist/index.js:123
        throw new TypeError(`Unexpected ${nextType} at ${index}, expected ${type}: ${DEBUG_URL}`);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions