Refactorings to make code cleaner. Fixes to not execute anything when windows squirrel installer.

This commit is contained in:
David Meza
2017-10-20 13:23:51 -05:00
parent 7a3552dfdc
commit c624a9a009
4 changed files with 29 additions and 17 deletions

View File

@@ -1,6 +1,10 @@
const REGEXP_DOMAIN = /(?:[^/]*\/){3}/;
const {URL} = require('url');
export function getDomain(url) {
const matched = url.match(REGEXP_DOMAIN);
return matched ? matched[0] : null;
try {
const objectUrl = new URL(url);
return objectUrl.origin;
} catch (e) {
return null;
}
}