From 3f8c98f2a89da42a9080b703abdbc09ecf0b7314 Mon Sep 17 00:00:00 2001 From: Jesse Wright <63333554+jeswr@users.noreply.github.com> Date: Sat, 28 Oct 2023 22:18:37 +0100 Subject: [PATCH] fix: deep copy imported contexts --- lib/ContextParser.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ContextParser.ts b/lib/ContextParser.ts index 64fe917..549a6d4 100644 --- a/lib/ContextParser.ts +++ b/lib/ContextParser.ts @@ -863,8 +863,8 @@ must be one of ${Util.CONTAINERS.join(', ')}`, ERROR_CODES.INVALID_CONTAINER_MAP * @param importContextIri The full URI of an @import value. */ public async loadImportContext(importContextIri: string): Promise { - // Load the context - const importContext = await this.load(importContextIri); + // Load the context - and do a deep clone since we are about to mutate it + const importContext = JSON.parse(JSON.stringify(await this.load(importContextIri))); // Require the context to be a non-array object if (typeof importContext !== 'object' || Array.isArray(importContext)) {