diff --git a/src/sdk.js b/src/sdk.js index 01528e6c3..f020ccd6f 100644 --- a/src/sdk.js +++ b/src/sdk.js @@ -99,11 +99,11 @@ class OpenForm { let pathname = this.useHashRouting ? '' : basePath || window.location.pathname; if (pathname.endsWith('/')) { - // ensure that the basename has no trailing slash (for react router) + // ensure that the pathname has no trailing slash (for react router) pathname = pathname.slice(0, pathname.length - 1); } this.routerBasePath = pathname; - this.basePath = this.useHashRouting ? window.location.pathname : pathname; + this.browserBasePath = this.useHashRouting ? window.location.pathname : pathname; this.makeRedirect(); this.calculateClientBaseUrl(); } @@ -122,7 +122,7 @@ class OpenForm { action, actionParams ); - const newUrl = new URL(this.routerBasePath, window.location.origin); + const newUrl = new URL(this.browserBasePath, window.location.origin); if (!this.useHashRouting) { newUrl.pathname += `${!newUrl.pathname.endsWith('/') ? '/' : ''}${redirectPath}`; // We first append query params from the redirect action @@ -134,9 +134,6 @@ class OpenForm { newUrl.searchParams.append(key, val); } } else { - // We know newUrl.pathname === '/', as this.routerBasePath is '' with hash based routing - newUrl.pathname += window.location.pathname.slice(1); - // First add extra unrelated query params, before hash (`#`) for (let [key, val] of query.entries()) { newUrl.searchParams.append(key, val); @@ -156,7 +153,7 @@ class OpenForm { calculateClientBaseUrl() { // calculate the client-side base URL, as this is recorded in backend calls for // submissions. - const clientBase = resolvePath(this.basePath).pathname; // has leading slash + const clientBase = resolvePath(this.browserBasePath).pathname; // has leading slash this.clientBaseUrl = new URL(clientBase, window.location.origin).href; }