From 13107daf263569c5ec32bfc3038a4a58f3b95ac2 Mon Sep 17 00:00:00 2001 From: Tim Jacomb <21194782+timja@users.noreply.github.com> Date: Sat, 12 Oct 2024 19:42:59 +0100 Subject: [PATCH] Handle domains with the word configure in them (#630) --- src/main/frontend/index.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/frontend/index.ts b/src/main/frontend/index.ts index e4cb05e6..0cb38429 100644 --- a/src/main/frontend/index.ts +++ b/src/main/frontend/index.ts @@ -30,10 +30,12 @@ document.addEventListener('DOMContentLoaded', () => { } } }) -const currentUrl = window.location.href + +const origin = window.location.origin +const pathname = window.location.pathname // GraphProxy is either a root action or at an item level -const endStrippedCurrentUrl = currentUrl +const endStrippedPathname = pathname .replace('configureSecurity/', '') .replace('configure', '') .replace('pipeline-syntax/', '') @@ -41,8 +43,15 @@ const endStrippedCurrentUrl = currentUrl .replace('cloud/create', '') .replace('computer/createItem', ''); +function appendSlashIfRequired(value: string) { + if (!value.endsWith("/")) { + return `${value}/` + } + return value +} -Providers.globalProvider = new ProxyProvider(`${endStrippedCurrentUrl}/GraphProxy`, async () => { +const url = `${origin}${appendSlashIfRequired(endStrippedPathname)}GraphProxy` +Providers.globalProvider = new ProxyProvider(url, async () => { return { [document.head.dataset.crumbHeader as string]: document.head.dataset.crumbValue, };