11import addFormats from 'ajv-formats' ;
22import Ajv from '@redocly/ajv/dist/2020.js' ;
33import { escapePointerFragment } from '../ref-utils.js' ;
4- import { slash } from '../utils/slash.js' ;
54
65import type { Location } from '../ref-utils.js' ;
76import type { ValidateFunction , ErrorObject } from '@redocly/ajv/dist/2020.js' ;
@@ -27,10 +26,14 @@ function getAjv(resolve: ResolveFn, allowAdditionalProperties: boolean) {
2726 validateFormats : true ,
2827 defaultUnevaluatedProperties : allowAdditionalProperties ,
2928 loadSchemaSync ( base : string , $ref : string , $id : string ) {
30- const resolvedRef = resolve ( { $ref } , slash ( base . split ( '#' ) [ 0 ] ) ) ;
29+ const decodedBase = decodeURI ( base . split ( '#' ) [ 0 ] ) ;
30+ const resolvedRef = resolve ( { $ref } , decodedBase ) ;
3131 if ( ! resolvedRef || ! resolvedRef . location ) return false ;
32- const normalizedAbsoluteRef = slash ( resolvedRef . location . source . absoluteRef ) ;
33- return { $id : normalizedAbsoluteRef + '#' + $id , ...resolvedRef . node } ;
32+
33+ return {
34+ $id : encodeURI ( resolvedRef . location . source . absoluteRef ) + '#' + $id ,
35+ ...resolvedRef . node ,
36+ } ;
3437 } ,
3538 logger : false ,
3639 } ) ;
@@ -46,7 +49,7 @@ function getAjvValidator(
4649 allowAdditionalProperties : boolean
4750) : ValidateFunction | undefined {
4851 const ajv = getAjv ( resolve , allowAdditionalProperties ) ;
49- const $id = encodeURI ( slash ( loc . absolutePointer ) ) ;
52+ const $id = encodeURI ( loc . absolutePointer ) ;
5053
5154 if ( ! ajv . getSchema ( $id ) ) {
5255 ajv . addSchema ( { $id, ...schema } , $id ) ;
0 commit comments