Skip to content

Commit

Permalink
dist: update
Browse files Browse the repository at this point in the history
  • Loading branch information
sagold committed Dec 6, 2024
1 parent 4eb6aa9 commit 4b1eef7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dist/jsonSchemaLibrary.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/lib/schemaNode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type SchemaNode = {
draft: Draft;
pointer: string;
schema: JsonSchema;
path: JsonSchema[];
path: [string, JsonSchema][];
next: typeof next;
merge: typeof merge;
resolveRef: typeof resolveRef;
Expand Down
12 changes: 7 additions & 5 deletions dist/module/lib/resolveRef.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,22 @@ function resolveRecursiveRef(node) {
// RESTRICT BY CHANGE IN BASE-URL
let startIndex = 0;
for (let i = history.length - 1; i >= 0; i--) {
if (history[i].$id && /^https?:\/\//.test(history[i].$id) && history[i].$recursiveAnchor !== true) {
const step = history[i][1];
if (step.$id && /^https?:\/\//.test(step.$id) && step.$recursiveAnchor !== true) {
startIndex = i;
break;
}
}
// FROM THERE FIND FIRST OCCURENCE OF ANCHOR
const firstAnchor = history.find((s, index) => index >= startIndex && s.$recursiveAnchor === true);
const firstAnchor = history.find((s, index) => index >= startIndex && s[1].$recursiveAnchor === true);
if (firstAnchor) {
return node.next(firstAnchor);
return node.next(firstAnchor[1]);
}
// THEN RETURN LATEST BASE AS TARGET
for (let i = history.length - 1; i >= 0; i--) {
if (history[i].$id) {
return node.next(history[i]);
const step = history[i][1];
if (step.$id) {
return node.next(step);
}
}
// OR RETURN ROOT
Expand Down
4 changes: 2 additions & 2 deletions dist/module/lib/schemaNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function merge(schema, ...omit) {
}
const node = this;
const mergedSchema = mergeSchema(node.schema, schema, ...omit);
return { ...node, schema: mergedSchema, path: [...node.path, node.schema] };
return { ...node, schema: mergedSchema, path: [...node.path, [node.pointer, node.schema]] };
}
function resolveRef() {
const node = this;
Expand All @@ -29,7 +29,7 @@ function next(schema, key) {
...node,
pointer: key ? `${node.pointer}/${key}` : node.pointer,
schema,
path: [...node.path, node.schema]
path: [...node.path, [node.pointer, node.schema]]
};
}
export function isSchemaNode(value) {
Expand Down

0 comments on commit 4b1eef7

Please sign in to comment.