summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/npm-registry-client/lib/adduser.js
diff options
context:
space:
mode:
authorTimothy J Fontaine <tjfontaine@gmail.com>2014-08-07 16:33:35 -0700
committerTimothy J Fontaine <tjfontaine@gmail.com>2014-08-07 16:33:35 -0700
commita5778cdf01425ae39cea80b62f9ec6740aec724a (patch)
tree6b011b6046ca68ee33e2cd811048f3e40558d7d9 /deps/npm/node_modules/npm-registry-client/lib/adduser.js
parent28eee0adb7884e21217c99cbf10a681c7d91b64a (diff)
parentb0277f35bd86d441255dc5a4c19e577e03f03a47 (diff)
downloadandroid-node-v8-a5778cdf01425ae39cea80b62f9ec6740aec724a.tar.gz
android-node-v8-a5778cdf01425ae39cea80b62f9ec6740aec724a.tar.bz2
android-node-v8-a5778cdf01425ae39cea80b62f9ec6740aec724a.zip
Merge remote-tracking branch 'upstream/v0.10' into v0.12
Conflicts: ChangeLog Makefile deps/uv/ChangeLog deps/uv/build.mk deps/uv/src/unix/darwin.c deps/uv/src/unix/getaddrinfo.c deps/uv/src/version.c deps/v8/src/checks.h deps/v8/src/isolate.h lib/cluster.js lib/module.js lib/timers.js lib/tls.js src/node_version.h
Diffstat (limited to 'deps/npm/node_modules/npm-registry-client/lib/adduser.js')
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/adduser.js24
1 files changed, 15 insertions, 9 deletions
diff --git a/deps/npm/node_modules/npm-registry-client/lib/adduser.js b/deps/npm/node_modules/npm-registry-client/lib/adduser.js
index 5a76b028c0..d1fcac8e91 100644
--- a/deps/npm/node_modules/npm-registry-client/lib/adduser.js
+++ b/deps/npm/node_modules/npm-registry-client/lib/adduser.js
@@ -1,6 +1,12 @@
module.exports = adduser
-function adduser (username, password, email, cb) {
+var url = require("url")
+
+function adduser (base, username, password, email, cb) {
+ if (!base) return cb(new Error("Required base URI not supplied"))
+
+ username = ("" + (username || "")).trim()
+ if (!username) return cb(new Error("No username supplied."))
password = ("" + (password || "")).trim()
if (!password) return cb(new Error("No password supplied."))
@@ -48,9 +54,10 @@ function adduser (username, password, email, cb) {
this.log.verbose("adduser", "before first PUT", logObj)
+ var uri = url.resolve(base, '/-/user/org.couchdb.user:' + encodeURIComponent(username))
this.request('PUT'
- , '/-/user/org.couchdb.user:'+encodeURIComponent(username)
- , userobj
+ , uri
+ , { body : userobj }
, function (error, data, json, response) {
// if it worked, then we just created a new user, and all is well.
// but if we're updating a current record, then it'll 409 first
@@ -69,8 +76,8 @@ function adduser (username, password, email, cb) {
this.log.verbose("adduser", "update existing user")
return this.request('GET'
- , '/-/user/org.couchdb.user:'+encodeURIComponent(username) +
- '?write=true'
+ , uri + '?write=true'
+ , null
, function (er, data, json, response) {
if (er || data.error) {
return cb(er, data, json, response)
@@ -82,10 +89,9 @@ function adduser (username, password, email, cb) {
})
this.log.verbose("adduser", "userobj", logObj)
this.request('PUT'
- , '/-/user/org.couchdb.user:'+encodeURIComponent(username)
- + "/-rev/" + userobj._rev
- , userobj
- , cb )
+ , uri + "/-rev/" + userobj._rev
+ , { body : userobj }
+ , cb)
}.bind(this))
}.bind(this))
}