Add http to url or logo when not present
This commit is contained in:
@ -3,6 +3,7 @@ import { History } from 'react-router';
|
|||||||
import { contain } from 'thundercats-react';
|
import { contain } from 'thundercats-react';
|
||||||
import debugFactory from 'debug';
|
import debugFactory from 'debug';
|
||||||
import dedent from 'dedent';
|
import dedent from 'dedent';
|
||||||
|
import normalizeUrl from 'normalize-url';
|
||||||
|
|
||||||
import { getDefaults } from '../utils';
|
import { getDefaults } from '../utils';
|
||||||
|
|
||||||
@ -83,6 +84,21 @@ function formatValue(value, validator, type = 'string') {
|
|||||||
return formated;
|
return formated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const normalizeOptions = {
|
||||||
|
stripWWW: false
|
||||||
|
};
|
||||||
|
|
||||||
|
function formatUrl(url) {
|
||||||
|
if (
|
||||||
|
typeof url === 'string' &&
|
||||||
|
url.length > 4 &&
|
||||||
|
url.indexOf('.') !== -1
|
||||||
|
) {
|
||||||
|
return normalizeUrl(url, normalizeOptions);
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
function isValidURL(data) {
|
function isValidURL(data) {
|
||||||
return isURL(data, { 'require_protocol': true });
|
return isURL(data, { 'require_protocol': true });
|
||||||
}
|
}
|
||||||
@ -100,7 +116,7 @@ export default contain({
|
|||||||
locale,
|
locale,
|
||||||
description,
|
description,
|
||||||
email,
|
email,
|
||||||
url = 'http://',
|
url,
|
||||||
logo,
|
logo,
|
||||||
company,
|
company,
|
||||||
isHighlighted,
|
isHighlighted,
|
||||||
@ -114,8 +130,8 @@ export default contain({
|
|||||||
locale: formatValue(locale, makeRequired(isAscii)),
|
locale: formatValue(locale, makeRequired(isAscii)),
|
||||||
description: formatValue(description, makeRequired(isAscii)),
|
description: formatValue(description, makeRequired(isAscii)),
|
||||||
email: formatValue(email, makeRequired(isEmail)),
|
email: formatValue(email, makeRequired(isEmail)),
|
||||||
url: formatValue(url, isValidURL),
|
url: formatValue(formatUrl(url), isValidURL),
|
||||||
logo: formatValue(logo, isValidURL),
|
logo: formatValue(formatUrl(logo), isValidURL),
|
||||||
company: formatValue(company, makeRequired(isAscii)),
|
company: formatValue(company, makeRequired(isAscii)),
|
||||||
isHighlighted: formatValue(isHighlighted, null, 'bool'),
|
isHighlighted: formatValue(isHighlighted, null, 'bool'),
|
||||||
isFullStackCert: formatValue(isFullStackCert, null, 'bool'),
|
isFullStackCert: formatValue(isFullStackCert, null, 'bool'),
|
||||||
|
@ -55,11 +55,11 @@
|
|||||||
"gulp-eslint": "~0.9.0",
|
"gulp-eslint": "~0.9.0",
|
||||||
"gulp-inject": "~1.0.2",
|
"gulp-inject": "~1.0.2",
|
||||||
"gulp-jsonlint": "^1.1.0",
|
"gulp-jsonlint": "^1.1.0",
|
||||||
|
"gulp-less": "^3.0.3",
|
||||||
|
"gulp-minify-css": "~0.5.1",
|
||||||
"gulp-nodemon": "^2.0.3",
|
"gulp-nodemon": "^2.0.3",
|
||||||
"gulp-notify": "^2.2.0",
|
"gulp-notify": "^2.2.0",
|
||||||
"gulp-plumber": "^1.0.1",
|
"gulp-plumber": "^1.0.1",
|
||||||
"gulp-less": "^3.0.3",
|
|
||||||
"gulp-minify-css": "~0.5.1",
|
|
||||||
"gulp-reduce-file": "0.0.1",
|
"gulp-reduce-file": "0.0.1",
|
||||||
"gulp-rev": "^6.0.1",
|
"gulp-rev": "^6.0.1",
|
||||||
"gulp-rev-replace": "^0.4.2",
|
"gulp-rev-replace": "^0.4.2",
|
||||||
@ -85,6 +85,7 @@
|
|||||||
"node-slack": "0.0.7",
|
"node-slack": "0.0.7",
|
||||||
"node-uuid": "^1.4.3",
|
"node-uuid": "^1.4.3",
|
||||||
"nodemailer": "~1.3.0",
|
"nodemailer": "~1.3.0",
|
||||||
|
"normalize-url": "^1.3.1",
|
||||||
"object.assign": "^3.0.0",
|
"object.assign": "^3.0.0",
|
||||||
"passport-facebook": "^2.0.0",
|
"passport-facebook": "^2.0.0",
|
||||||
"passport-github": "^0.1.5",
|
"passport-github": "^0.1.5",
|
||||||
|
Reference in New Issue
Block a user