diff --git a/ui/desktop/CHANGELOG.md b/ui/desktop/CHANGELOG.md index 34bb51bf9..5726e86f2 100644 --- a/ui/desktop/CHANGELOG.md +++ b/ui/desktop/CHANGELOG.md @@ -6,7 +6,8 @@ Canonical reference for changes, improvements, and bugfixes for Boundary Desktop ### Bug Fixes -- ui: Trigger zoom-in menu option on keyboard shortcut. ([PR](https://github.com/hashicorp/boundary-ui/pull/505)) +- Trigger zoom-in menu option on keyboard shortcut. ([PR](https://github.com/hashicorp/boundary-ui/pull/505)) +- Boundary Desktop will accept origins with or without trailing slashes. ([PR](https://github.com/hashicorp/boundary-ui/pull/519)) ## v1.0.0-beta [CLI 0.1.8] (2021.03.10) diff --git a/ui/desktop/app/services/origin.js b/ui/desktop/app/services/origin.js index a5c1f3a0e..9ca0895f2 100644 --- a/ui/desktop/app/services/origin.js +++ b/ui/desktop/app/services/origin.js @@ -63,6 +63,10 @@ export default class OriginService extends Service { typeof origin === 'string' ); try { + // Silently drop trailing slashes if present. + // This is important since API paths that will be appended to the origin + // will include preceeding slashes already. + origin = origin.replace(/\/*$/, ''); this.adapter.host = origin; this.rendererOrigin = origin; if (origin !== (await this.mainOrigin)) { diff --git a/ui/desktop/electron-app/yarn.lock b/ui/desktop/electron-app/yarn.lock index 58a5e01a5..45dcdf0a4 100644 --- a/ui/desktop/electron-app/yarn.lock +++ b/ui/desktop/electron-app/yarn.lock @@ -3562,7 +3562,7 @@ xmlbuilder@^9.0.7: resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-9.0.7.tgz#132ee63d2ec5565c557e20f4c22df9aca686b10d" integrity sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0= -xmldom@0.1.x, xmldom@0.5.0: +xmldom@0.1.x, xmldom@~0.5.0: version "0.5.0" resolved "https://registry.yarnpkg.com/xmldom/-/xmldom-0.5.0.tgz#193cb96b84aa3486127ea6272c4596354cb4962e" integrity sha512-Foaj5FXVzgn7xFzsKeNIde9g6aFBxTPi37iwsno8QvApmtg7KYrr+OPyRHcJF7dud2a5nGRBXK3n0dL62Gf7PA== diff --git a/ui/desktop/tests/unit/services/origin-test.js b/ui/desktop/tests/unit/services/origin-test.js index 4d8703cf6..cc6cdfa69 100644 --- a/ui/desktop/tests/unit/services/origin-test.js +++ b/ui/desktop/tests/unit/services/origin-test.js @@ -24,4 +24,15 @@ module('Unit | Service | origin', function (hooks) { assert.equal(service.adapter.host, window.location.origin); }); }); + + test('drops trailing slashes from origin on setOrigin', async function (assert) { + assert.expect(4); + sinon.stub(ipcService, 'invoke'); + await service.setOrigin(`${window.location.origin}/`); + assert.equal(service.rendererOrigin, window.location.origin); + assert.equal(service.adapter.host, window.location.origin); + await service.setOrigin(`${window.location.origin}//////`); + assert.equal(service.rendererOrigin, window.location.origin); + assert.equal(service.adapter.host, window.location.origin); + }); });