diff options
Diffstat (limited to 'deps/npm/node_modules/npm-user-validate/npm-user-validate.js')
-rw-r--r-- | deps/npm/node_modules/npm-user-validate/npm-user-validate.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/deps/npm/node_modules/npm-user-validate/npm-user-validate.js b/deps/npm/node_modules/npm-user-validate/npm-user-validate.js index 3a645ec932..9250ce33a4 100644 --- a/deps/npm/node_modules/npm-user-validate/npm-user-validate.js +++ b/deps/npm/node_modules/npm-user-validate/npm-user-validate.js @@ -1,19 +1,23 @@ exports.email = email exports.pw = pw exports.username = username - var requirements = exports.requirements = { username: { length: 'Name length must be less than or equal to 214 characters long', lowerCase: 'Name must be lowercase', urlSafe: 'Name may not contain non-url-safe chars', - dot: 'Name may not start with "."' + dot: 'Name may not start with "."', + illegal: 'Name may not contain illegal character' }, password: {}, email: { valid: 'Email must be an email address' } -}; +} + +var illegalCharacterRe = new RegExp('([' + [ + "'" +].join() + '])') function username (un) { if (un !== un.toLowerCase()) { @@ -32,6 +36,11 @@ function username (un) { return new Error(requirements.username.length) } + var illegal = un.match(illegalCharacterRe) + if (illegal) { + return new Error(requirements.username.illegal + ' "' + illegal[0] + '"') + } + return null } |