From f949f23d6df668819faa6a4baaaaae998a7c4d0c Mon Sep 17 00:00:00 2001 From: Scott Aubrey Date: Thu, 21 Dec 2023 07:42:47 +0000 Subject: [PATCH] add ability to replace temporary paths in linked resources --- src/app.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/app.ts b/src/app.ts index 4b6bf1b..1630c87 100644 --- a/src/app.ts +++ b/src/app.ts @@ -29,25 +29,27 @@ app.post('/', async (req, res) => { }, }; + const replacementPath = typeof req.query.replacementPath === 'string' ? req.query.replacementPath : ''; + const versionResponders = { 'application/vnd.elife.encoda.v1.0.3+json': async () => { res.json({ version: '1.0.3', - json: await convert_1_0_3(xmlFile, undefined, parameters), + json: (await convert_1_0_3(xmlFile, undefined, parameters))?.replaceAll(tempOutput, replacementPath), }); rmdirSync(tempOutput, { recursive: true }); }, 'application/vnd.elife.encoda.v1.0.2+json': async () => { res.json({ version: '1.0.2', - json: await convert_1_0_2(xmlFile, undefined, parameters), + json: (await convert_1_0_2(xmlFile, undefined, parameters))?.replaceAll(tempOutput, replacementPath), }); rmdirSync(tempOutput, { recursive: true }); }, 'application/vnd.elife.encoda.v1.0.1+json': async () => { res.json({ version: '1.0.1', - json: await convert_1_0_1(xmlFile, undefined, parameters), + json: (await convert_1_0_1(xmlFile, undefined, parameters))?.replaceAll(tempOutput, replacementPath), }); rmdirSync(tempOutput, { recursive: true }); },