fast-json-stringify 5.0.5 → 5.0.6

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/index.js CHANGED
@@ -55,7 +55,7 @@ function resolveRef (location, ref) {
55
55
  }
56
56
 
57
57
  const schemaId = ref.slice(0, hashIndex) || location.schemaId
58
- const jsonPointer = ref.slice(hashIndex)
58
+ const jsonPointer = ref.slice(hashIndex) || '#'
59
59
 
60
60
  const schemaRef = schemaId + jsonPointer
61
61
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fast-json-stringify",
3
- "version": "5.0.5",
3
+ "version": "5.0.6",
4
4
  "description": "Stringify your JSON at max speed",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "homepage": "https://github.com/fastify/fast-json-stringify#readme",
35
35
  "devDependencies": {
36
- "@sinclair/typebox": "^0.23.3",
36
+ "@sinclair/typebox": "^0.24.9",
37
37
  "benchmark": "^2.1.4",
38
38
  "cli-select": "^1.1.2",
39
39
  "compile-json-stringify": "^0.1.2",
package/test/ref.test.js CHANGED
@@ -1926,3 +1926,30 @@ test('anyOf inside allOf', (t) => {
1926
1926
 
1927
1927
  t.equal(output, JSON.stringify(object))
1928
1928
  })
1929
+
1930
+ test('should resolve absolute $refs', (t) => {
1931
+ t.plan(1)
1932
+
1933
+ const externalSchema = {
1934
+ FooSchema: {
1935
+ $id: 'FooSchema',
1936
+ type: 'object',
1937
+ properties: {
1938
+ type: {
1939
+ anyOf: [
1940
+ { type: 'string', const: 'bar' },
1941
+ { type: 'string', const: 'baz' }
1942
+ ]
1943
+ }
1944
+ }
1945
+ }
1946
+ }
1947
+
1948
+ const schema = { $ref: 'FooSchema' }
1949
+
1950
+ const object = { type: 'bar' }
1951
+ const stringify = build(schema, { schema: externalSchema })
1952
+ const output = stringify(object)
1953
+
1954
+ t.equal(output, JSON.stringify(object))
1955
+ })