Validate url before building the app

This commit is contained in:
Jia Hao 2016-01-18 23:56:59 +08:00
parent 10c1a9c97a
commit 5411e9c71a
2 changed files with 9 additions and 1 deletions

View File

@ -27,7 +27,8 @@
"commander": "^2.9.0",
"electron-packager": "^5.2.1",
"ncp": "^2.0.0",
"tmp": "0.0.28"
"tmp": "0.0.28",
"validator": "^4.5.0"
},
"babel": {
"presets": [

View File

@ -1,6 +1,8 @@
import os from 'os';
import path from 'path';
import validator from 'validator';
const TEMPLATE_APP_DIR = path.join(__dirname, '../', 'app');
const ELECTRON_VERSION = '0.36.4';
@ -16,6 +18,11 @@ function optionsFactory(name = 'MyApp',
badge = false,
width = 1280,
height = 800) {
if (!validator.isURL(targetUrl, {require_protocol: true})) {
throw 'Your Url is invalid!, did you remember to include \'http://\'?';
}
return {
dir: TEMPLATE_APP_DIR,