Update publishHelpers.js

Accept space in filename from user, and replace the space to dash. Since a lot of users are used to typing out with spaces, better UX and less errors thrown out for invalid names.
This commit is contained in:
Shaikh Farhan 2017-07-22 18:47:46 +05:30 committed by GitHub
parent c6b2d2fed1
commit 49f1fb8745

View file

@ -30,6 +30,8 @@ module.exports = {
if (invalidCharacters) { if (invalidCharacters) {
throw new Error('The name you provided is not allowed. Please use A-Z, a-z, 0-9, and "-" only.'); throw new Error('The name you provided is not allowed. Please use A-Z, a-z, 0-9, and "-" only.');
} }
name = str.replace(/\s+/g, '-'); //replace space with dash/hyphen
// validate license // validate license
if ((license.indexOf('Public Domain') === -1) && (license.indexOf('Creative Commons') === -1)) { if ((license.indexOf('Public Domain') === -1) && (license.indexOf('Creative Commons') === -1)) {
throw new Error('Only posts with a license of "Public Domain" or "Creative Commons" are eligible for publishing through spee.ch'); throw new Error('Only posts with a license of "Public Domain" or "Creative Commons" are eligible for publishing through spee.ch');