|
1 |
| -import Pointer from "./pointer.js"; |
| 1 | +import Pointer, { nullSymbol } from "./pointer.js"; |
2 | 2 | import type { JSONParserError, MissingPointerError, ParserError, ResolverError } from "./util/errors.js";
|
3 | 3 | import { InvalidPointerError, isHandledError, normalizeError } from "./util/errors.js";
|
4 | 4 | import { safePointerToPath, stripHash, getHash } from "./util/url.js";
|
@@ -119,7 +119,12 @@ class $Ref<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOpt
|
119 | 119 | resolve(path: string, options?: O, friendlyPath?: string, pathFromRoot?: string) {
|
120 | 120 | const pointer = new Pointer<S, O>(this, path, friendlyPath);
|
121 | 121 | try {
|
122 |
| - return pointer.resolve(this.value, options, pathFromRoot); |
| 122 | + const resolved = pointer.resolve(this.value, options, pathFromRoot); |
| 123 | + if (resolved.value === nullSymbol) { |
| 124 | + resolved.value = null; |
| 125 | + } |
| 126 | + |
| 127 | + return resolved; |
123 | 128 | } catch (err: any) {
|
124 | 129 | if (!options || !options.continueOnError || !isHandledError(err)) {
|
125 | 130 | throw err;
|
@@ -148,6 +153,9 @@ class $Ref<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOpt
|
148 | 153 | set(path: string, value: any) {
|
149 | 154 | const pointer = new Pointer(this, path);
|
150 | 155 | this.value = pointer.set(this.value, value);
|
| 156 | + if (this.value === nullSymbol) { |
| 157 | + this.value = null; |
| 158 | + } |
151 | 159 | }
|
152 | 160 |
|
153 | 161 | /**
|
|
0 commit comments