@@ -946,13 +946,13 @@ async function _retrieveContextUrls(input, options) {
946
946
const documentLoader = util . normalizeDocumentLoader ( options . documentLoader ) ;
947
947
948
948
// retrieve all @context URLs in input
949
- await retrieve ( input , { } , documentLoader ) ;
949
+ await retrieve ( input , new Set ( ) , documentLoader ) ;
950
950
951
951
return input ;
952
952
953
953
// recursive function that will retrieve all @context URLs in documents
954
954
async function retrieve ( doc , cycles , documentLoader ) {
955
- if ( Object . keys ( cycles ) . length > MAX_CONTEXT_URLS ) {
955
+ if ( cycles . size > MAX_CONTEXT_URLS ) {
956
956
throw new JsonLdError (
957
957
'Maximum number of @context URLs exceeded.' ,
958
958
'jsonld.ContextUrlError' ,
@@ -969,15 +969,15 @@ async function _retrieveContextUrls(input, options) {
969
969
// retrieve URLs in queue
970
970
return Promise . all ( queue . map ( async url => {
971
971
// check for context URL cycle
972
- if ( url in cycles ) {
972
+ if ( cycles . has ( url ) ) {
973
973
throw new JsonLdError (
974
974
'Cyclical @context URLs detected.' ,
975
975
'jsonld.ContextUrlError' ,
976
976
{ code : 'recursive context inclusion' , url} ) ;
977
977
}
978
978
979
- const _cycles = util . clone ( cycles ) ;
980
- _cycles [ url ] = true ;
979
+ const _cycles = new Set ( cycles ) ;
980
+ _cycles . add ( url ) ;
981
981
let remoteDoc ;
982
982
let ctx ;
983
983
0 commit comments