fastify 5.3.0 → 5.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/Guides/Benchmarking.md +1 -1
- package/fastify.js +1 -1
- package/lib/validation.js +11 -1
- package/package.json +1 -1
- package/test/custom-parser.0.test.js +160 -129
- package/test/custom-parser.1.test.js +77 -63
- package/test/custom-querystring-parser.test.js +46 -28
- package/test/logger/instantiation.test.js +89 -96
- package/test/logger/logging.test.js +116 -120
- package/test/logger/options.test.js +97 -99
- package/test/logger/request.test.js +66 -66
- package/test/schema-validation.test.js +136 -0
- package/test/stream.4.test.js +38 -33
- package/test/toolkit.js +31 -0
|
@@ -12,7 +12,7 @@ The modules we will use:
|
|
|
12
12
|
tool written in node.
|
|
13
13
|
- [Branch-comparer](https://github.com/StarpTech/branch-comparer): Checkout
|
|
14
14
|
multiple git branches, execute scripts, and log the results.
|
|
15
|
-
- [Concurrently](https://github.com/
|
|
15
|
+
- [Concurrently](https://github.com/open-cli-tools/concurrently): Run commands
|
|
16
16
|
concurrently.
|
|
17
17
|
- [Npx](https://github.com/npm/npx): NPM package runner used to run scripts
|
|
18
18
|
against different Node.js Versions and execute local binaries. Shipped with
|
package/fastify.js
CHANGED
package/lib/validation.js
CHANGED
|
@@ -155,7 +155,7 @@ function validate (context, request, execution) {
|
|
|
155
155
|
validatorFunction = context[bodySchema]
|
|
156
156
|
} else if (context[bodySchema]) {
|
|
157
157
|
// TODO: add request.contentType and reuse it here
|
|
158
|
-
const contentType = request.headers['content-type']
|
|
158
|
+
const contentType = getEssenceMediaType(request.headers['content-type'])
|
|
159
159
|
const contentSchema = context[bodySchema][contentType]
|
|
160
160
|
if (contentSchema) {
|
|
161
161
|
validatorFunction = contentSchema
|
|
@@ -254,6 +254,16 @@ function wrapValidationError (result, dataVar, schemaErrorFormatter) {
|
|
|
254
254
|
return error
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
+
/**
|
|
258
|
+
* simple function to retrieve the essence media type
|
|
259
|
+
* @param {string} header
|
|
260
|
+
* @returns {string} Mimetype string.
|
|
261
|
+
*/
|
|
262
|
+
function getEssenceMediaType (header) {
|
|
263
|
+
if (!header) return ''
|
|
264
|
+
return header.split(/[ ;]/, 1)[0].trim().toLowerCase()
|
|
265
|
+
}
|
|
266
|
+
|
|
257
267
|
module.exports = {
|
|
258
268
|
symbols: { bodySchema, querystringSchema, responseSchema, paramsSchema, headersSchema },
|
|
259
269
|
compileSchemasForValidation,
|