@@ -171,23 +171,21 @@ export class CoreSchemaRegistry implements SchemaRegistry {
171
171
ref : string ,
172
172
validate : ajv . ValidateFunction ,
173
173
) : { context ?: ajv . ValidateFunction , schema ?: JsonObject } {
174
- if ( ! validate ) {
174
+ if ( ! validate || ! validate . refs || ! validate . refVal || ! ref ) {
175
175
return { } ;
176
176
}
177
177
178
- const refHash = ref . split ( '#' , 2 ) [ 1 ] ;
179
- const refUrl = ref . startsWith ( '#' ) ? ref : ref . split ( '#' , 1 ) ;
180
-
181
- if ( ! ref . startsWith ( '#' ) ) {
182
- // tslint:disable-next-line:no-any
183
- validate = ( validate . refVal as any ) [ ( validate . refs as any ) [ refUrl [ 0 ] ] ] ;
184
- }
185
- if ( validate && refHash ) {
186
- // tslint:disable-next-line:no-any
187
- validate = ( validate . refVal as any ) [ ( validate . refs as any ) [ '#' + refHash ] ] ;
178
+ // tslint:disable-next-line:no-any
179
+ const id = ( validate . schema as any ) . $id || ( validate . schema as any ) . id ;
180
+ let fullReference = ( ref [ 0 ] === '#' && id ) ? id + ref : ref ;
181
+ if ( fullReference . endsWith ( '#' ) ) {
182
+ fullReference = fullReference . slice ( 0 , - 1 ) ;
188
183
}
189
184
190
- return { context : validate , schema : validate && validate . schema as JsonObject } ;
185
+ // tslint:disable-next-line:no-any
186
+ const context = validate . refVal [ ( validate . refs as any ) [ fullReference ] ] ;
187
+
188
+ return { context, schema : context && context . schema as JsonObject } ;
191
189
}
192
190
193
191
compile ( schema : JsonObject ) : Observable < SchemaValidator > {
0 commit comments