Merge branch 'main' into fix-hiding-update-dialog
This commit is contained in:
2 files changed
+13
-1
No files matched your search
@@ -63,9 +63,10 @@ export default class OriginService extends Service {
|
||||
typeof origin === 'string'
|
||||
);
|
||||
try {
|
||||
// Silently drop trailing slashes if present.
|
||||
// Trim whitespaces and 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.trim();
|
||||
origin = origin.replace(/\/*$/, '');
|
||||
this.adapter.host = origin;
|
||||
this.rendererOrigin = origin;
|
||||
|
||||
@@ -35,4 +35,15 @@ module('Unit | Service | origin', function (hooks) {
|
||||
assert.equal(service.rendererOrigin, window.location.origin);
|
||||
assert.equal(service.adapter.host, window.location.origin);
|
||||
});
|
||||
|
||||
test('trim spaces 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