11import { SchemaNode } from "../types" ;
22import { Keyword , JsonSchemaValidatorParams , ValidationPath , JsonSchemaReducerParams } from "../Keyword" ;
3- import { joinId } from "../utils/joinId " ;
3+ import { resolveUri } from "../utils/resolveUri " ;
44import splitRef from "../utils/splitRef" ;
55import { omit } from "../utils/omit" ;
66import { isObject } from "../utils/isObject" ;
@@ -31,7 +31,7 @@ export function parseRef(node: SchemaNode) {
3131 node . resolveRef = resolveRef ;
3232
3333 // get and store current $id of node - this may be the same as parent $id
34- const currentId = joinId ( node . parent ?. $id , node . schema ?. $id ) ;
34+ const currentId = resolveUri ( node . parent ?. $id , node . schema ?. $id ) ;
3535 node . $id = currentId ;
3636 node . lastIdPointer = node . parent ?. lastIdPointer ?? "#" ;
3737 if ( currentId !== node . parent ?. $id && node . evaluationPath !== "#" ) {
@@ -41,10 +41,10 @@ export function parseRef(node: SchemaNode) {
4141 // store this node for retrieval by $id + json-pointer from $id
4242 if ( node . lastIdPointer !== "#" && node . evaluationPath . startsWith ( node . lastIdPointer ) ) {
4343 const localPointer = `#${ node . evaluationPath . replace ( node . lastIdPointer , "" ) } ` ;
44- register ( node , joinId ( currentId , localPointer ) ) ;
44+ register ( node , resolveUri ( currentId , localPointer ) ) ;
4545 }
4646 // store $rootId + json-pointer to this node
47- register ( node , joinId ( node . context . rootNode . $id , node . evaluationPath ) ) ;
47+ register ( node , resolveUri ( node . context . rootNode . $id , node . evaluationPath ) ) ;
4848
4949 // @draft -2020: A $dynamicRef to a $dynamicAnchor in the same schema resource behaves like a normal $ref to an $anchor
5050 const anchor = node . schema . $anchor ;
@@ -67,7 +67,7 @@ export function parseRef(node: SchemaNode) {
6767
6868 // precompile reference
6969 if ( node . schema . $ref ) {
70- node . $ref = joinId ( currentId , node . schema . $ref ) ;
70+ node . $ref = resolveUri ( currentId , node . schema . $ref ) ;
7171 if ( node . $ref . startsWith ( "/" ) ) {
7272 node . $ref = `#${ node . $ref } ` ;
7373 }
@@ -124,7 +124,7 @@ function validateRef({ node, data, pointer = "#", path }: JsonSchemaValidatorPar
124124// 1. https://json-schema.org/draft/2019-09/json-schema-core#scopes
125125function resolveRecursiveRef ( node : SchemaNode , path : ValidationPath ) : SchemaNode {
126126 const history = path ;
127- const refInCurrentScope = joinId ( node . $id , node . schema . $dynamicRef ) ;
127+ const refInCurrentScope = resolveUri ( node . $id , node . schema . $dynamicRef ) ;
128128
129129 // A $dynamicRef with a non-matching $dynamicAnchor in the same schema resource behaves like a normal $ref to $anchor
130130 const nonMatchingDynamicAnchor = node . context . dynamicAnchors [ refInCurrentScope ] == null ;
@@ -142,7 +142,7 @@ function resolveRecursiveRef(node: SchemaNode, path: ValidationPath): SchemaNode
142142
143143 // A $dynamicRef only stops at a $dynamicAnchor if it is in the same dynamic scope.
144144 const refWithoutScope = node . schema . $dynamicRef . split ( "#" ) . pop ( ) ;
145- const ref = joinId ( history [ i ] . node . $id , `#${ refWithoutScope } ` ) ;
145+ const ref = resolveUri ( history [ i ] . node . $id , `#${ refWithoutScope } ` ) ;
146146 const anchorNode = node . context . dynamicAnchors [ ref ] ;
147147 if ( anchorNode ) {
148148 return compileNext ( node . context . dynamicAnchors [ ref ] , node ) ;
0 commit comments