expressjs / expressjs/express

`App.use(path, ...)` Does Not Mount at `'//'`

Open
#4,557 7 comments 0 reactions 0 assignees View on GitHub
bug module:router
Dominant language
JavaScript
Stars
69.5k
Forks
25k
Avg merge
4d 20h
Merged PRs (30d)
9

Description

`Router` instance mounted explicitly at `'//'` exposes routes when path begins only with a single `/`:

```javascript
const TestRoutes = express.Router();

TestRoutes.get('/drop/table/:table', (req, res) => {
// drop table
res.send(`Dropped table '${req.params.table}'`);
})

TestRoutes.get('/', sendListOfTestRoutes);

if (TEST) app.use('//', TestRoutes);

app.listen();
```

Expected behavior is that navigating to `http://hostname/` would bypass this `Router` and go to the main app, but instead Express serves the list of test routes mounted within the router at `//`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.