fast-json-stringify
Advanced tools
Comparing version 5.14.0 to 5.14.1
@@ -441,3 +441,3 @@ 'use strict' | ||
if (key === '$ref' && value.charAt(0) === '#') { | ||
if (key === '$ref' && typeof value === 'string' && value.charAt(0) === '#') { | ||
value = schemaId + value | ||
@@ -444,0 +444,0 @@ } |
{ | ||
"name": "fast-json-stringify", | ||
"version": "5.14.0", | ||
"version": "5.14.1", | ||
"description": "Stringify your JSON at max speed", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -720,1 +720,37 @@ 'use strict' | ||
}) | ||
test('do not crash with $ref prop', (t) => { | ||
t.plan(1) | ||
const schema = { | ||
title: 'object with $ref', | ||
type: 'object', | ||
properties: { | ||
outside: { | ||
$ref: '#/$defs/outside' | ||
} | ||
}, | ||
$defs: { | ||
inside: { | ||
type: 'object', | ||
properties: { | ||
$ref: { | ||
type: 'string' | ||
} | ||
} | ||
}, | ||
outside: { | ||
allOf: [{ | ||
$ref: '#/$defs/inside' | ||
}] | ||
} | ||
} | ||
} | ||
const stringify = build(schema) | ||
const value = stringify({ | ||
outside: { | ||
$ref: 'true' | ||
} | ||
}) | ||
t.equal(value, '{"outside":{"$ref":"true"}}') | ||
}) |
364220
13682