mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2024-09-22 09:39:02 +00:00
Refactor options to seperate folders
This commit is contained in:
parent
4663b99050
commit
6ddf84bee1
@ -5,7 +5,7 @@ import ncp from 'ncp';
|
|||||||
import async from 'async';
|
import async from 'async';
|
||||||
import hasBinary from 'hasbin';
|
import hasBinary from 'hasbin';
|
||||||
|
|
||||||
import optionsFactory from './../options';
|
import optionsFactory from './../options/optionsMain';
|
||||||
import iconBuild from './iconBuild';
|
import iconBuild from './iconBuild';
|
||||||
import helpers from './../helpers/helpers';
|
import helpers from './../helpers/helpers';
|
||||||
import buildApp from './buildApp';
|
import buildApp from './buildApp';
|
||||||
|
17
src/options/normalizeUrl.js
Normal file
17
src/options/normalizeUrl.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import url from 'url';
|
||||||
|
import validator from 'validator';
|
||||||
|
|
||||||
|
function normalizeUrl(testUrl) {
|
||||||
|
// add protocol if protocol not found
|
||||||
|
let normalized = testUrl;
|
||||||
|
const parsed = url.parse(normalized);
|
||||||
|
if (!parsed.protocol) {
|
||||||
|
normalized = 'http://' + normalized;
|
||||||
|
}
|
||||||
|
if (!validator.isURL(normalized, {require_protocol: true, require_tld: false})) {
|
||||||
|
throw `Your Url: "${normalized}" is invalid!`;
|
||||||
|
}
|
||||||
|
return normalized;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default normalizeUrl;
|
@ -1,19 +1,18 @@
|
|||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import url from 'url';
|
|
||||||
import validator from 'validator';
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import async from 'async';
|
import async from 'async';
|
||||||
import sanitizeFilename from 'sanitize-filename';
|
import sanitizeFilename from 'sanitize-filename';
|
||||||
|
|
||||||
import inferIcon from './infer/inferIcon';
|
import inferIcon from './../infer/inferIcon';
|
||||||
import inferTitle from './infer/inferTitle';
|
import inferTitle from './../infer/inferTitle';
|
||||||
import inferOs from './infer/inferOs';
|
import inferOs from './../infer/inferOs';
|
||||||
import packageJson from './../package.json';
|
import normalizeUrl from './normalizeUrl';
|
||||||
|
import packageJson from './../../package.json';
|
||||||
|
|
||||||
const {inferPlatform, inferArch} = inferOs;
|
const {inferPlatform, inferArch} = inferOs;
|
||||||
|
|
||||||
const PLACEHOLDER_APP_DIR = path.join(__dirname, '../', 'app');
|
const PLACEHOLDER_APP_DIR = path.join(__dirname, '../../', 'app');
|
||||||
const ELECTRON_VERSION = '0.36.4';
|
const ELECTRON_VERSION = '0.36.4';
|
||||||
const DEFAULT_APP_NAME = 'APP';
|
const DEFAULT_APP_NAME = 'APP';
|
||||||
|
|
||||||
@ -100,19 +99,6 @@ function sanitizeOptions(options) {
|
|||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeUrl(testUrl) {
|
|
||||||
// add protocol if protocol not found
|
|
||||||
let normalized = testUrl;
|
|
||||||
const parsed = url.parse(normalized);
|
|
||||||
if (!parsed.protocol) {
|
|
||||||
normalized = 'http://' + normalized;
|
|
||||||
}
|
|
||||||
if (!validator.isURL(normalized, {require_protocol: true, require_tld: false})) {
|
|
||||||
throw `Your Url: "${normalized}" is invalid!`;
|
|
||||||
}
|
|
||||||
return normalized;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getFakeUserAgent() {
|
function getFakeUserAgent() {
|
||||||
let userAgent;
|
let userAgent;
|
||||||
switch (os.platform()) {
|
switch (os.platform()) {
|
Loading…
Reference in New Issue
Block a user