Skip to content

Using wildcard routes "*" or "/*" in Express v5 causes path-to-regexp to throw an error due to broken parameter parsing. #6606

@kabukabu1000

Description

@kabukabu1000

Issue: Using wildcard routes * or /* in Express v5 causes path-to-regexp to throw an error due to broken parameter parsing.

Error:

/home/*****/node_modules/path-to-regexp/dist/index.js:73
            throw new TypeError(`Missing parameter name at ${i}: ${DEBUG_URL}`);
            ^

TypeError: Missing parameter name at 2: https://git.new/pathToRegexpError
    at name (/home/*****/node_modules/path-to-regexp/dist/index.js:73:19)
    at lexer (/home/*****/node_modules/path-to-regexp/dist/index.js:91:27)
    at lexer.next (<anonymous>)
    at Iter.peek (/home/*****/node_modules/path-to-regexp/dist/index.js:106:38)
    at Iter.tryConsume (/home/*****/node_modules/path-to-regexp/dist/index.js:112:28)
    at Iter.text (/home/*****/node_modules/path-to-regexp/dist/index.js:128:30)
    at consume (/home/*****/node_modules/path-to-regexp/dist/index.js:152:29)
    at parse (/home/*****/node_modules/path-to-regexp/dist/index.js:183:20)
    at /home/*****/node_modules/path-to-regexp/dist/index.js:294:74
    at Array.map (<anonymous>)

Details:
When defining routes with * or /* patterns in Express 5.x, path-to-regexp fails to parse the route pattern properly, throwing a Missing parameter name error. This breaks wildcard routing functionality.

Environment information

Version:
"dependencies": {
"express": "^5.1.0",
"sqlite3": "^5.1.7"
}

Platform:
Ubuntu 24.04.2 LTS

Node.js version:
Node.js v22.17.0

What steps will reproduce the bug?

  1. Define a route in Express v5 using the wildcard patterns * or /*.
const app = express();

app.get('/*', (req, res) => {
  res.send('Wildcard route');
});

app.listen(3000, () => {
  console.log('Server started on port 3000');
});
  1. Start the Node.js server with this route configuration.

  2. Access any path (e.g., http://localhost:3000/anything) in a browser or HTTP client.

  3. The server will throw a TypeError: Missing parameter name from path-to-regexp, causing the crash.

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