expressjs / expressjs/express

Strict Routing

Open
#3,798 8 comments 0 reactions 0 assignees View on GitHub
4.x awaiting more info
Dominant language
JavaScript
Stars
69.5k
Forks
25k
Avg merge
4d 20h
Merged PRs (30d)
9

Description

I've been experimenting with strict routing using `express@latest` and have found that the following the requests all route to the same path when supplying `strict: true` to express. This doesn't seem to uphold the docs explanation of `Disabled by default, “/foo” and “/foo/” are treated the same by the router.`.

```js
const express = require('express')
const app = express({ strict: true })
const port = 3022

app.get('/:param?/', (req, res) => res.json(req.params.param));

app.listen(port);
```

```
> curl -I http://localhost:3022/
HTTP/1.1 200 OK

> curl -I http://localhost:3022/abc
HTTP/1.1 200 OK

> curl -I http://localhost:3022/abc/
HTTP/1.1 200 OK
```

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.