Skip to content

Commit 943f3e5

Browse files
committed
enforce the same min/max length limit to backend
1 parent be3d8e7 commit 943f3e5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

routes/redirect.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ module.exports = Router()
1010
res.redirect(301, process.env.HOMEPAGE)
1111
})
1212
.get(`/:hash(${schema.Link.properties.hash.pattern})`, async (req, res) => {
13+
if (
14+
req.params.hash.length < schema.Link.properties.hash.minLength ||
15+
req.params.hash.length > schema.Link.properties.hash.maxLength
16+
)
17+
return res.sendStatus(404)
18+
1319
const link = await Link.query()
1420
.findByHashId(req.params.hash)
1521
.throwIfNotFound()

0 commit comments

Comments
 (0)