diff --git a/src/acp/control.internal.ts b/src/acp/control.internal.ts index f319f77a57..7ffa24df7c 100644 --- a/src/acp/control.internal.ts +++ b/src/acp/control.internal.ts @@ -24,7 +24,7 @@ import type { ThingPersisted, Url, UrlString } from "../interfaces"; import { getSourceUrl } from "../resource/resource"; import { internal_cloneResource } from "../resource/resource.internal"; import { addIri } from "../thing/add"; -import { getIriAll } from "../thing/get"; +import { getIriAll, getUrlAll } from "../thing/get"; import { removeAll, removeIri } from "../thing/remove"; import { setIri } from "../thing/set"; import { @@ -165,7 +165,12 @@ export function internal_setControl( let updatedAcr = setThing(acr, control); const acrSubj = getThing(updatedAcr, getSourceUrl(acr)); // If the ACR has an anchor node, link the Access Control. - if (acrSubj !== null) { + if ( + acrSubj !== null && + getUrlAll(acrSubj, acp.accessControl).every( + (object) => object.toString() !== asIri(control, getSourceUrl(acr)), + ) + ) { updatedAcr = setThing( updatedAcr, addIri(acrSubj, acp.accessControl, asIri(control, getSourceUrl(acr))),