Skip to content

Strict Routing #3798

@sabrehagen

Description

@sabrehagen

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..

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions