mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-27 13:16:36 +00:00
minifix(GUI): don't call shell.openExternal if resource is undefined (#622)
This PR fixes an uncaught error being thrown when `OSOpenExternalService.open()` is called with an undefined value. Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
This commit is contained in:
parent
c31b45200d
commit
7fa4178161
@ -30,6 +30,10 @@ module.exports = function() {
|
|||||||
* @example
|
* @example
|
||||||
* OSOpenExternalService.open('https://www.google.com');
|
* OSOpenExternalService.open('https://www.google.com');
|
||||||
*/
|
*/
|
||||||
this.open = electron.shell.openExternal;
|
this.open = (url) => {
|
||||||
|
if (url) {
|
||||||
|
electron.shell.openExternal(url);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -52,6 +52,15 @@ describe('Browser: OSOpenExternal', function() {
|
|||||||
shellExternalStub.restore();
|
shellExternalStub.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not call Electron shell.openExternal if the attribute value is not defined', function() {
|
||||||
|
const shellExternalStub = m.sinon.stub(electron.shell, 'openExternal');
|
||||||
|
const element = $compile('<span os-open-external>Resin.io</span>')($rootScope);
|
||||||
|
element.triggerHandler('click');
|
||||||
|
$rootScope.$digest();
|
||||||
|
m.chai.expect(shellExternalStub).to.not.have.been.called;
|
||||||
|
shellExternalStub.restore();
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user