diff --git a/common/app/routes/Jobs/components/NewJob.jsx b/common/app/routes/Jobs/components/NewJob.jsx index 3da9ca8f3b..7a2c61f7a5 100644 --- a/common/app/routes/Jobs/components/NewJob.jsx +++ b/common/app/routes/Jobs/components/NewJob.jsx @@ -3,6 +3,7 @@ import { History } from 'react-router'; import { contain } from 'thundercats-react'; import debugFactory from 'debug'; import dedent from 'dedent'; +import normalizeUrl from 'normalize-url'; import { getDefaults } from '../utils'; @@ -83,6 +84,21 @@ function formatValue(value, validator, type = 'string') { 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) { return isURL(data, { 'require_protocol': true }); } @@ -100,7 +116,7 @@ export default contain({ locale, description, email, - url = 'http://', + url, logo, company, isHighlighted, @@ -114,8 +130,8 @@ export default contain({ locale: formatValue(locale, makeRequired(isAscii)), description: formatValue(description, makeRequired(isAscii)), email: formatValue(email, makeRequired(isEmail)), - url: formatValue(url, isValidURL), - logo: formatValue(logo, isValidURL), + url: formatValue(formatUrl(url), isValidURL), + logo: formatValue(formatUrl(logo), isValidURL), company: formatValue(company, makeRequired(isAscii)), isHighlighted: formatValue(isHighlighted, null, 'bool'), isFullStackCert: formatValue(isFullStackCert, null, 'bool'), diff --git a/package.json b/package.json index c4777546c9..10697a1778 100644 --- a/package.json +++ b/package.json @@ -55,11 +55,11 @@ "gulp-eslint": "~0.9.0", "gulp-inject": "~1.0.2", "gulp-jsonlint": "^1.1.0", + "gulp-less": "^3.0.3", + "gulp-minify-css": "~0.5.1", "gulp-nodemon": "^2.0.3", "gulp-notify": "^2.2.0", "gulp-plumber": "^1.0.1", - "gulp-less": "^3.0.3", - "gulp-minify-css": "~0.5.1", "gulp-reduce-file": "0.0.1", "gulp-rev": "^6.0.1", "gulp-rev-replace": "^0.4.2", @@ -85,6 +85,7 @@ "node-slack": "0.0.7", "node-uuid": "^1.4.3", "nodemailer": "~1.3.0", + "normalize-url": "^1.3.1", "object.assign": "^3.0.0", "passport-facebook": "^2.0.0", "passport-github": "^0.1.5",