From 46f460aee36dcc59949da5b713668a72222dd88e Mon Sep 17 00:00:00 2001 From: SilviaAmAm Date: Thu, 23 Nov 2023 12:18:53 +0100 Subject: [PATCH 1/2] :alembic: Attempt hot-fix for hash based routing --- src/sdk.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/sdk.js b/src/sdk.js index 22deef75b..00c98a1f1 100644 --- a/src/sdk.js +++ b/src/sdk.js @@ -95,12 +95,17 @@ class OpenForm { CSPNonce.setValue(CSPNonceValue); initialiseSentry(sentryDSN, sentryEnv); - // ensure that the basename has no trailing slash (for react router) - let pathname = basePath || window.location.pathname; - if (pathname.endsWith('/')) { - pathname = pathname.slice(0, pathname.length - 1); + if (useHashRouting) { + this.basePath = ''; + } else { + // ensure that the basename has no trailing slash (for react router) + let pathname = basePath || window.location.pathname; + if (pathname.endsWith('/')) { + pathname = pathname.slice(0, pathname.length - 1); + } + this.basePath = pathname; } - this.basePath = pathname; + this.calculateClientBaseUrl(); } From 406e53af4d7fbf3b3292e387bf635e6143def4b1 Mon Sep 17 00:00:00 2001 From: SilviaAmAm Date: Thu, 23 Nov 2023 12:30:39 +0100 Subject: [PATCH 2/2] :white_check_mark: Fix test for hot-fix hashbased routing --- src/sdk.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdk.spec.js b/src/sdk.spec.js index e9e4e7d15..ebc55b23d 100644 --- a/src/sdk.spec.js +++ b/src/sdk.spec.js @@ -136,6 +136,6 @@ describe('OpenForm', () => { useHashRouting: true, }); - expect(form.clientBaseUrl).toEqual('http://localhost/some-server-side/path#/some-subpath'); + expect(form.clientBaseUrl).toEqual('http://localhost/some-server-side/path#/'); }); });