1
0
Fork 0
mirror of synced 2024-10-03 19:43:32 +13:00

_bb client api, relative url checks for root path,+ handles absolutes

This commit is contained in:
Michael Shanks 2020-02-27 21:14:41 +00:00
parent 1c3fd54929
commit 39075b5032

View file

@ -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), {