-
-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(validator): check for json subtypes in validator #2634
feat(validator): check for json subtypes in validator #2634
Conversation
deno_dist/validator/validator.ts
Outdated
@@ -67,7 +67,7 @@ export const validator = < | |||
|
|||
switch (target) { | |||
case 'json': | |||
if (!contentType || !contentType.startsWith('application/json')) { | |||
if (!contentType || !contentType.match(/^application\/[a-z-]*\+json(\s*;.*)?$/)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- You should use the
test
instead of thematch
if you don't capture strings. ^application\/[a-z-]*\+
should beapplication\/([a-z-]+\+)*
.- The last
(\s*;.*)?
is necessary?
Thanks!
|
Hi @ztiromoritz Thanks! Looks good. To avoid the CI error, could you run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Hi @ztiromoritz Thank you for your contribution. I'll merge this into the main now and will release it in a |
Fine. My pleasure. |
(Hope this is according to the projects workflow. 😁 ) |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [hono](https://hono.dev/) ([source](https://github.com/honojs/hono)) | [`4.3.0` -> `4.3.6`](https://renovatebot.com/diffs/npm/hono/4.3.0/4.3.6) | [![age](https://developer.mend.io/api/mc/badges/age/npm/hono/4.3.6?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/hono/4.3.6?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/hono/4.3.0/4.3.6?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/hono/4.3.0/4.3.6?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>honojs/hono (hono)</summary> ### [`v4.3.6`](https://github.com/honojs/hono/releases/tag/v4.3.6) [Compare Source](https://github.com/honojs/hono/compare/v4.3.5...v4.3.6) #### What's Changed - feat(cache): improved customizability by [@​MathurAditya724](https://github.com/MathurAditya724) in [https://github.com/honojs/hono/pull/2652](https://github.com/honojs/hono/pull/2652) - fix(utils/body): support multiple `File`s by [@​yusukebe](https://github.com/yusukebe) in [https://github.com/honojs/hono/pull/2665](https://github.com/honojs/hono/pull/2665) #### New Contributors - [@​MathurAditya724](https://github.com/MathurAditya724) made their first contribution in [https://github.com/honojs/hono/pull/2652](https://github.com/honojs/hono/pull/2652) **Full Changelog**: honojs/hono@v4.3.5...v4.3.6 ### [`v4.3.5`](https://github.com/honojs/hono/releases/tag/v4.3.5) [Compare Source](https://github.com/honojs/hono/compare/v4.3.4...v4.3.5) #### What's Changed - refactor(context): remove some `any` by [@​yusukebe](https://github.com/yusukebe) in [https://github.com/honojs/hono/pull/2658](https://github.com/honojs/hono/pull/2658) - feat(hono-base): tweaks `fetch` signature for better compatibility with `deno serve` by [@​usualoma](https://github.com/usualoma) in [https://github.com/honojs/hono/pull/2661](https://github.com/honojs/hono/pull/2661) - perf(types): add type annotations by [@​yusukebe](https://github.com/yusukebe) in [https://github.com/honojs/hono/pull/2663](https://github.com/honojs/hono/pull/2663) **Full Changelog**: honojs/hono@v4.3.4...v4.3.5 ### [`v4.3.4`](https://github.com/honojs/hono/releases/tag/v4.3.4) [Compare Source](https://github.com/honojs/hono/compare/v4.3.3...v4.3.4) #### What's Changed - chore: update the pull request template by [@​yusukebe](https://github.com/yusukebe) in [https://github.com/honojs/hono/pull/2647](https://github.com/honojs/hono/pull/2647) - feat(validator): check for json subtypes in validator by [@​ztiromoritz](https://github.com/ztiromoritz) in [https://github.com/honojs/hono/pull/2634](https://github.com/honojs/hono/pull/2634) - feat(jsx/dom): support getServerSnapshot in useSyncExternalStore by [@​usualoma](https://github.com/usualoma) in [https://github.com/honojs/hono/pull/2646](https://github.com/honojs/hono/pull/2646) #### New Contributors - [@​ztiromoritz](https://github.com/ztiromoritz) made their first contribution in [https://github.com/honojs/hono/pull/2634](https://github.com/honojs/hono/pull/2634) **Full Changelog**: honojs/hono@v4.3.3...v4.3.4 ### [`v4.3.3`](https://github.com/honojs/hono/releases/tag/v4.3.3) [Compare Source](https://github.com/honojs/hono/compare/v4.3.2...v4.3.3) #### What's Changed - fix(types): relax the type of `c.req.param()` by [@​yusukebe](https://github.com/yusukebe) in [https://github.com/honojs/hono/pull/2613](https://github.com/honojs/hono/pull/2613) - chore(eslint): enable `@typescript-eslint/unbound-method` by [@​yusukebe](https://github.com/yusukebe) in [https://github.com/honojs/hono/pull/2622](https://github.com/honojs/hono/pull/2622) - fix(factory): support `createFactory()` destruction by [@​yusukebe](https://github.com/yusukebe) in [https://github.com/honojs/hono/pull/2623](https://github.com/honojs/hono/pull/2623) - fix(aws-lambda): avoid duplicating already set headers by [@​Amorim33](https://github.com/Amorim33) in [https://github.com/honojs/hono/pull/2585](https://github.com/honojs/hono/pull/2585) - refactor: improve parseBody function and docs by [@​mgrithm](https://github.com/mgrithm) in [https://github.com/honojs/hono/pull/2628](https://github.com/honojs/hono/pull/2628) - fix(validator): `form` supports multiple values with `foo[]` by [@​yusukebe](https://github.com/yusukebe) in [https://github.com/honojs/hono/pull/2639](https://github.com/honojs/hono/pull/2639) #### New Contributors - [@​Amorim33](https://github.com/Amorim33) made their first contribution in [https://github.com/honojs/hono/pull/2585](https://github.com/honojs/hono/pull/2585) **Full Changelog**: honojs/hono@v4.3.2...v4.3.3 ### [`v4.3.2`](https://github.com/honojs/hono/releases/tag/v4.3.2) [Compare Source](https://github.com/honojs/hono/compare/v4.3.1...v4.3.2) #### What's Changed - fix(types): correct inferring when Method has Endponts as Union by [@​yusukebe](https://github.com/yusukebe) in [https://github.com/honojs/hono/pull/2610](https://github.com/honojs/hono/pull/2610) **Full Changelog**: honojs/hono@v4.3.1...v4.3.2 ### [`v4.3.1`](https://github.com/honojs/hono/releases/tag/v4.3.1) [Compare Source](https://github.com/honojs/hono/compare/v4.3.0...v4.3.1) #### What's Changed - fix(types): `ToSchema` compatibility by [@​NamesMT](https://github.com/NamesMT) in [https://github.com/honojs/hono/pull/2605](https://github.com/honojs/hono/pull/2605) **Full Changelog**: honojs/hono@v4.3.0...v4.3.1 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on Monday" in timezone America/Chicago, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/autoblocksai/cli). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNDAuMTAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4zNTEuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
A minimal fix for #2633 using a regex.
I liked the simplicity of the current
startsWith
-approach but it excluded subtypes.I did:
bun denoify
to generate files for Deno