File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -88,18 +88,18 @@ function parseHttpHeaders(httpHeaders: Record<string, any>): Headers {
8888interface LoadOptions extends GlobalContext {
8989 rootURL : URL ;
9090 schemas : SchemaMap ;
91+ urlCache ?: Set < string > ; // URL cache (prevent URLs from being loaded over and over)
9192 httpHeaders ?: Headers ;
9293 httpMethod ?: string ;
9394}
9495
95- // temporary cache for load()
96- let urlCache = new Set < string > ( ) ; // URL cache (prevent URLs from being loaded over and over)
97-
9896/** Load a schema from local path or remote URL */
9997export default async function load (
10098 schema : URL | PartialSchema ,
10199 options : LoadOptions
102100) : Promise < { [ url : string ] : PartialSchema } > {
101+ const urlCache = options . urlCache || new Set < string > ( ) ;
102+
103103 const isJSON = schema instanceof URL === false ; // if this is dynamically-passed-in JSON, we’ll have to change a few things
104104 let schemaID = isJSON ? new URL ( VIRTUAL_JSON_URL ) . href : ( schema . href as string ) ;
105105
@@ -182,7 +182,7 @@ export default async function load(
182182
183183 const nextURL = isRemoteURL ? new URL ( refURL ) : new URL ( slash ( refURL ) , schema as URL ) ;
184184 refPromises . push (
185- load ( nextURL , options ) . then ( ( subschemas ) => {
185+ load ( nextURL , { ... options , urlCache } ) . then ( ( subschemas ) => {
186186 for ( const subschemaURL of Object . keys ( subschemas ) ) {
187187 schemas [ subschemaURL ] = subschemas [ subschemaURL ] ;
188188 }
You can’t perform that action at this time.
0 commit comments