Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/npm-user-validate/npm-user-validate.js')
-rw-r--r--node_modules/npm-user-validate/npm-user-validate.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/node_modules/npm-user-validate/npm-user-validate.js b/node_modules/npm-user-validate/npm-user-validate.js
index 3a645ec93..9250ce33a 100644
--- a/node_modules/npm-user-validate/npm-user-validate.js
+++ b/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
}