From 92fec07fc0202691b9fd0578cc519e2242b1cbf6 Mon Sep 17 00:00:00 2001 From: Vladimir Ignatov Date: Mon, 26 Jul 2021 12:19:00 -0400 Subject: [PATCH] #57 --- src/simple-proxy.js | 3 ++- test/fhir-servers.js | 43 +++++++++++++++++++++++-------------------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/simple-proxy.js b/src/simple-proxy.js index e77bbcab..b7cfe587 100644 --- a/src/simple-proxy.js +++ b/src/simple-proxy.js @@ -192,7 +192,8 @@ module.exports = (req, res) => { }); if (!isBinary) { - stream = stream.pipe(replStream(fhirServer, `${config.baseUrl}/v/${fhirVersionLower}/fhir`)); + // stream = stream.pipe(replStream(fhirServer, `${config.baseUrl}/v/${fhirVersionLower}/fhir`)); + stream = stream.pipe(replStream(fhirServer, `${Lib.getRequestBaseURL(req)}/v/${fhirVersionLower}/fhir`)); } stream.pipe(res); diff --git a/test/fhir-servers.js b/test/fhir-servers.js index 3087c38f..22eef095 100644 --- a/test/fhir-servers.js +++ b/test/fhir-servers.js @@ -274,8 +274,7 @@ for(const FHIR_VERSION in TESTED_FHIR_SERVERS) { }); it ("Handles pagination", () => { - return agent.get(`${PATH_FHIR}/Patient`) - .expect(res => { + return agent.get(`${PATH_FHIR}/Patient`).expect(async (res) => { if (!Array.isArray(res.body.link)) { throw new Error("No links found"); } @@ -284,26 +283,30 @@ for(const FHIR_VERSION in TESTED_FHIR_SERVERS) { if (!next) { throw new Error("No next link found"); } - // console.log(next) - return agent.get(next.url).expect(res2 => { - if (!Array.isArray(res.body.link)) { - throw new Error("No links found on second page"); - } + + const nextURL = new URL(next.url) + + const res2 = await request(app).get(nextURL.pathname + nextURL.search) + + if (!Array.isArray(res2.body.link)) { + throw new Error("No links found on second page"); + } - let self = res.body.link.find(l => l.relation == "self") - if (!self) { - throw new Error("No self link found on second page"); - } - if (self.url !== next.url) { - throw new Error("Links mismatch"); - } + let self = res2.body.link.find(l => l.relation == "self") + + if (!self) { + throw new Error("No self link found on second page"); + } + + if (self.url !== next.url) { + throw new Error("Links mismatch"); + } - let next2 = res.body.link.find(l => l.relation == "next") - if (!next2) { - throw new Error("No next link found on second page"); - } - // console.log(next2) - }) + let next2 = res.body.link.find(l => l.relation == "next") + + if (!next2) { + throw new Error("No next link found on second page"); + } }) });