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(); } 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#/'); }); });