@@ -112,7 +112,7 @@ export function compileSchema(this: Ajv, sch: SchemaEnv): SchemaEnv {
112
112
// TODO refactor - remove compilations
113
113
const _sch = getCompilingSchema . call ( this , sch )
114
114
if ( _sch ) return _sch
115
- const rootId = getFullPath ( sch . root . baseId ) // TODO if getFullPath removed 1 tests fails
115
+ const rootId = getFullPath ( this . opts . uriResolver , sch . root . baseId ) // TODO if getFullPath removed 1 tests fails
116
116
const { es5, lines} = this . opts . code
117
117
const { ownProperties} = this . opts
118
118
const gen = new CodeGen ( this . scope , { es5, lines, ownProperties} )
@@ -208,7 +208,7 @@ export function resolveRef(
208
208
baseId : string ,
209
209
ref : string
210
210
) : AnySchema | SchemaEnv | undefined {
211
- ref = resolveUrl ( baseId , ref )
211
+ ref = resolveUrl ( this . opts . uriResolver , baseId , ref )
212
212
const schOrFunc = root . refs [ ref ]
213
213
if ( schOrFunc ) return schOrFunc
214
214
@@ -257,9 +257,9 @@ export function resolveSchema(
257
257
root : SchemaEnv , // root object with properties schema, refs TODO below SchemaEnv is assigned to it
258
258
ref : string // reference to resolve
259
259
) : SchemaEnv | undefined {
260
- const p = URI . parse ( ref )
261
- const refPath = _getFullPath ( p )
262
- let baseId = getFullPath ( root . baseId )
260
+ const p = this . opts . uriResolver . parse ( ref )
261
+ const refPath = _getFullPath ( this . opts . uriResolver , p )
262
+ let baseId = getFullPath ( this . opts . uriResolver , root . baseId , undefined )
263
263
// TODO `Object.keys(root.schema).length > 0` should not be needed - but removing breaks 2 tests
264
264
if ( Object . keys ( root . schema ) . length > 0 && refPath === baseId ) {
265
265
return getJsonPointer . call ( this , p , root )
@@ -279,7 +279,7 @@ export function resolveSchema(
279
279
const { schema} = schOrRef
280
280
const { schemaId} = this . opts
281
281
const schId = schema [ schemaId ]
282
- if ( schId ) baseId = resolveUrl ( baseId , schId )
282
+ if ( schId ) baseId = resolveUrl ( this . opts . uriResolver , baseId , schId )
283
283
return new SchemaEnv ( { schema, schemaId, root, baseId} )
284
284
}
285
285
return getJsonPointer . call ( this , p , schOrRef )
@@ -307,12 +307,12 @@ function getJsonPointer(
307
307
// TODO PREVENT_SCOPE_CHANGE could be defined in keyword def?
308
308
const schId = typeof schema === "object" && schema [ this . opts . schemaId ]
309
309
if ( ! PREVENT_SCOPE_CHANGE . has ( part ) && schId ) {
310
- baseId = resolveUrl ( baseId , schId )
310
+ baseId = resolveUrl ( this . opts . uriResolver , baseId , schId )
311
311
}
312
312
}
313
313
let env : SchemaEnv | undefined
314
314
if ( typeof schema != "boolean" && schema . $ref && ! schemaHasRulesButRef ( schema , this . RULES ) ) {
315
- const $ref = resolveUrl ( baseId , schema . $ref )
315
+ const $ref = resolveUrl ( this . opts . uriResolver , baseId , schema . $ref )
316
316
env = resolveSchema . call ( this , root , $ref )
317
317
}
318
318
// even though resolution failed we need to return SchemaEnv to throw exception
0 commit comments