Merge branch 'main' into fix-styles

This commit is contained in:
Susmitha Girumala authored and GitHub committed 2021-04-14 09:37:35 -04:00
commit eaaeed6d1b
3 files changed
+30 -18

No files matched your search

+2 -1
View File
@@ -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;
+17 -17
View File
@@ -90,7 +90,7 @@ const downloadAndInstallUpdate = async (version) => {
* TODO: download progress in dialog
**/
module.exports = {
run: async ({ suppressNoUpdatePrompt }) => {
run: async ({ suppressNoUpdatePrompt } = {}) => {
let latestVersion;
if (debug) {
latestVersion = process.env.APP_UPDATER_LATEST_VERSION_TAG;
@@ -104,7 +104,8 @@ module.exports = {
}
// Update not available - do nothing
if (!suppressNoUpdatePrompt && semver.lte(latestVersion, currentVersion)) {
if (semver.lte(latestVersion, currentVersion)) {
if (suppressNoUpdatePrompt) return;
const dialogOpts = {
type: 'info',
icon: null,
@@ -112,21 +113,20 @@ module.exports = {
};
dialog.showMessageBox(dialogOpts);
return;
} else {
// Update is available - prompt for download
const dialogOpts = {
type: 'info',
buttons: ['Download', 'Later'],
icon: null,
detail: 'A new version is available for download',
};
dialog.showMessageBox(dialogOpts).then((returnValue) => {
if (returnValue.response === 0) {
downloadAndInstallUpdate(latestVersion);
}
});
}
// Update is available - prompt for download
const dialogOpts = {
type: 'info',
buttons: ['Download', 'Later'],
icon: null,
detail: 'A new version is available for download',
};
dialog.showMessageBox(dialogOpts).then((returnValue) => {
if (returnValue.response === 0) {
downloadAndInstallUpdate(latestVersion);
}
});
},
};
@@ -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);
});
});