Merge pull request #519 from hashicorp/fix-origin-trailing-slash
fix: 🐛 silently drop trailing slashes from origin input - ICU-1293
This commit is contained in:
4 files changed
+18
-2
No files matched your search
@@ -6,7 +6,8 @@ Canonical reference for changes, improvements, and bugfixes for Boundary Desktop
|
|||||||
|
|
||||||
### Bug Fixes
|
### 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)
|
## v1.0.0-beta [CLI 0.1.8] (2021.03.10)
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,10 @@ export default class OriginService extends Service {
|
|||||||
typeof origin === 'string'
|
typeof origin === 'string'
|
||||||
);
|
);
|
||||||
try {
|
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.adapter.host = origin;
|
||||||
this.rendererOrigin = origin;
|
this.rendererOrigin = origin;
|
||||||
if (origin !== (await this.mainOrigin)) {
|
if (origin !== (await this.mainOrigin)) {
|
||||||
|
|||||||
@@ -3562,7 +3562,7 @@ xmlbuilder@^9.0.7:
|
|||||||
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-9.0.7.tgz#132ee63d2ec5565c557e20f4c22df9aca686b10d"
|
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-9.0.7.tgz#132ee63d2ec5565c557e20f4c22df9aca686b10d"
|
||||||
integrity sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=
|
integrity sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=
|
||||||
|
|
||||||
xmldom@0.1.x, xmldom@0.5.0:
|
xmldom@0.1.x, xmldom@~0.5.0:
|
||||||
version "0.5.0"
|
version "0.5.0"
|
||||||
resolved "https://registry.yarnpkg.com/xmldom/-/xmldom-0.5.0.tgz#193cb96b84aa3486127ea6272c4596354cb4962e"
|
resolved "https://registry.yarnpkg.com/xmldom/-/xmldom-0.5.0.tgz#193cb96b84aa3486127ea6272c4596354cb4962e"
|
||||||
integrity sha512-Foaj5FXVzgn7xFzsKeNIde9g6aFBxTPi37iwsno8QvApmtg7KYrr+OPyRHcJF7dud2a5nGRBXK3n0dL62Gf7PA==
|
integrity sha512-Foaj5FXVzgn7xFzsKeNIde9g6aFBxTPi37iwsno8QvApmtg7KYrr+OPyRHcJF7dud2a5nGRBXK3n0dL62Gf7PA==
|
||||||
|
|||||||
@@ -24,4 +24,15 @@ module('Unit | Service | origin', function (hooks) {
|
|||||||
assert.equal(service.adapter.host, window.location.origin);
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
Reference in new issue
Block a user