From b7a5bab47cdc2e6a9d1b0d24fe6367bace6d19eb Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Thu, 27 Feb 2020 21:14:41 +0000 Subject: [PATCH] _bb client api, relative url checks for root path,+ handles absolutes --- packages/client/src/state/bbComponentApi.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/client/src/state/bbComponentApi.js b/packages/client/src/state/bbComponentApi.js index d130a4b7ae..75b00bd5dc 100644 --- a/packages/client/src/state/bbComponentApi.js +++ b/packages/client/src/state/bbComponentApi.js @@ -13,10 +13,14 @@ export const bbFactory = ({ uiFunctions, onScreenSlotRendered, }) => { - const relativeUrl = url => - frontendDefinition.appRootPath - ? frontendDefinition.appRootPath + "/" + trimSlash(url) - : url + const relativeUrl = url => { + if (!frontendDefinition.appRootPath) return url + if (url.startsWith("http:") + || url.startsWith("https:") + || url.startsWith("./")) return url + + return frontendDefinition.appRootPath + "/" + trimSlash(url) + } const apiCall = method => (url, body) => fetch(relativeUrl(url), {