Aktueller Stand
This commit is contained in:
7
backend/node_modules/fast-json-stringify/lib/serializer.js
generated
vendored
7
backend/node_modules/fast-json-stringify/lib/serializer.js
generated
vendored
@@ -92,7 +92,9 @@ module.exports = class Serializer {
|
||||
|
||||
asString (str) {
|
||||
const len = str.length
|
||||
if (len < 42) {
|
||||
if (len === 0) {
|
||||
return '""'
|
||||
} else if (len < 42) {
|
||||
// magically escape strings for json
|
||||
// relying on their charCodeAt
|
||||
// everything below 32 needs JSON.stringify()
|
||||
@@ -102,8 +104,7 @@ module.exports = class Serializer {
|
||||
let result = ''
|
||||
let last = -1
|
||||
let point = 255
|
||||
// eslint-disable-next-line
|
||||
for (var i = 0; i < len; i++) {
|
||||
for (let i = 0; i < len; i++) {
|
||||
point = str.charCodeAt(i)
|
||||
if (
|
||||
point === 0x22 || // '"'
|
||||
|
||||
10
backend/node_modules/fast-json-stringify/lib/validator.js
generated
vendored
10
backend/node_modules/fast-json-stringify/lib/validator.js
generated
vendored
@@ -21,8 +21,8 @@ class Validator {
|
||||
keyword: 'fjs_type',
|
||||
type: 'object',
|
||||
errors: false,
|
||||
validate: (type, date) => {
|
||||
return date instanceof Date
|
||||
validate: (_type, data) => {
|
||||
return data && typeof data.toJSON === 'function'
|
||||
}
|
||||
})
|
||||
|
||||
@@ -51,8 +51,10 @@ class Validator {
|
||||
return this.ajv.validate(schemaRef, data)
|
||||
}
|
||||
|
||||
// Ajv does not support js date format. In order to properly validate objects containing a date,
|
||||
// it needs to replace all occurrences of the string date format with a custom keyword fjs_type.
|
||||
// Ajv does not natively support JavaScript objects like Date or other types
|
||||
// that rely on a custom .toJSON() representation. To properly validate schemas
|
||||
// that may contain such objects (e.g. Date, ObjectId, etc.), we replace all
|
||||
// occurrences of the string type with a custom keyword fjs_type
|
||||
// (see https://github.com/fastify/fast-json-stringify/pull/441)
|
||||
convertSchemaToAjvFormat (schema) {
|
||||
if (schema === null) return
|
||||
|
||||
Reference in New Issue
Block a user