From e16dfef88e465a0f7b54b78d4f80eff95761866b Mon Sep 17 00:00:00 2001 From: Travis Rich Date: Wed, 19 Aug 2026 18:54:04 -0400 Subject: [PATCH] Quick fix for cms dois without custom paths --- server/doi/__tests__/api.test.ts | 26 ++++++++++++++++++++++++++ server/doi/queries.ts | 3 +++ 2 files changed, 29 insertions(+) diff --git a/server/doi/__tests__/api.test.ts b/server/doi/__tests__/api.test.ts index 99f73d4f84..fdfec7ff10 100644 --- a/server/doi/__tests__/api.test.ts +++ b/server/doi/__tests__/api.test.ts @@ -30,6 +30,17 @@ const models = modelize` } } } + Community cmsCommunity { + cmsMode: true + canonicalBaseUrl: "https://cms.example.org" + Member { + permissions: "admin" + User cmsCommunityAdmin {} + } + Pub cmsPub { + Release {} + } + } User guest {} `; @@ -179,4 +190,19 @@ it('lets community admins preview a DOI for collections in their community', asy expect(previewDois.collection).toEqual(expectedCollectionDoi); }); +it('deposits the canonical url for a CMS-mode community', async () => { + const { cmsCommunityAdmin, cmsCommunity, cmsPub } = models; + const agent = await login(cmsCommunityAdmin); + const { + body: { depositJson }, + } = await agent + .get('/api/doiPreview') + .query({ target: 'pub', pubId: cmsPub.id, communityId: cmsCommunity.id }) + .expect(200); + + const depositXml = JSON.stringify(depositJson.deposit); + expect(depositXml).toContain(`https://cms.example.org/pub/${cmsPub.slug}`); + expect(depositXml).not.toContain('pubpub.org'); +}); + teardown(afterAll); diff --git a/server/doi/queries.ts b/server/doi/queries.ts index ce276df3d0..70122a8e95 100644 --- a/server/doi/queries.ts +++ b/server/doi/queries.ts @@ -68,6 +68,9 @@ const findCommunity = (communityId) => 'subdomain', 'citeAs', 'publishAs', + // cmsMode gates canonicalCommunityUrl, so it must be selected here or + // deposits fall back to the pubpub.org URL for CMS-mode communities. + 'cmsMode', 'canonicalBaseUrl', 'canonicalPubUrlTemplate', ],