Skip to content

Commit a1e44da

Browse files
committed
fix: deep copy imported contexts
1 parent e3519d2 commit a1e44da

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/ContextParser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,13 +816,13 @@ must be one of ${Util.CONTAINERS.join(', ')}`, ERROR_CODES.INVALID_CONTAINER_MAP
816816
// First try to retrieve the context from cache
817817
const cached = this.documentCache[url];
818818
if (cached) {
819-
return typeof cached === 'string' ? cached : Array.isArray(cached) ? cached.slice() : {... cached};
819+
return typeof cached === 'string' ? cached : JSON.parse(JSON.stringify(cached));
820820
}
821821

822822
// If not in cache, load it
823823
let document: IJsonLdContext;
824824
try {
825-
document = await this.documentLoader.load(url);
825+
document = JSON.parse(JSON.stringify(await this.documentLoader.load(url)));
826826
} catch (e) {
827827
throw new ErrorCoded(`Failed to load remote context ${url}: ${e.message}`,
828828
ERROR_CODES.LOADING_REMOTE_CONTEXT_FAILED);

0 commit comments

Comments
 (0)