hapijs / hapijs/crumb

PUT / DELETE requests don't do crumb validation

Open
#161 0 comments 0 reactions 0 assignees View on GitHub
support
Dominant language
JavaScript
Stars
170
Forks
47
PR merge metrics
No merged PRs in 30d

Description

It's very common in other frameworks to do REST routes as such:

```
(request: Request, h: ResponseToolkit): symbol => {
if (request.method === 'post' && request.url.searchParams.has('_method')) {
const override = request.url.searchParams.get('_method');
request.setMethod(override);
}

return h.continue;
};
```

These are some example routes:

```
{
path: '/articles',
method: 'POST',
options: {
validate: {
payload: Joi.object({
name: Joi.string(),
});
},
},
handler: store,
},
{
path: '/articles/{slug}',
method: 'PUT',
options: {
validate: {
payload: Joi.object({
name: Joi.string(),
});
},
},
handler: save,
},
```

POST will succeed, PUT will fail because

```
errors: {
"crumb": "\"crumb\" is not allowed"
}
```

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.