Permalink
Browse files

[minor] encode all usernames passed as parameters to ensure paths are…

… hit
  • Loading branch information...
Swaagie committed Dec 16, 2014
1 parent ead0582 commit 8fb4ad5bfbdc127823b27469dc3f4ecdb45ee673
Showing with 31 additions and 8 deletions.
  1. +30 −7 node.js/lib/client/users.js
  2. +1 −1 node.js/package.json
@@ -42,7 +42,11 @@ Users.prototype.auth = function (callback) {
// Creates a new user with the properties specified by `user`.
//
Users.prototype.create = function (user, callback) {
- this.request({ method: 'POST', uri: ['users', user.username], body: user }, callback);
+ this.request({
+ method: 'POST',
+ uri: ['users', encodeURIComponent(user.username)],
+ body: user
+ }, callback);
};
//
@@ -52,7 +56,9 @@ Users.prototype.create = function (user, callback) {
// Checks the availability of the specified `username`.
//
Users.prototype.available = function (username, callback) {
- this.request({ uri: ['users', encodeURIComponent(username), 'available'] }, callback);
+ this.request({
+ uri: ['users', encodeURIComponent(username), 'available']
+ }, callback);
};
//
@@ -73,7 +79,9 @@ Users.prototype.emailTaken = function (email, callback) {
// Retrieves data for the specified user.
//
Users.prototype.view = function (username, callback) {
- this.request({ uri: ['users', username] }, callback);
+ this.request({
+ uri: ['users', encodeURIComponent(username)]
+ }, callback);
};
//
@@ -83,7 +91,11 @@ Users.prototype.view = function (username, callback) {
// Confirms the specified `user` by sending the invite code in the `user` specified.
//
Users.prototype.confirm = function (user, callback) {
- this.request({ method: 'POST', uri: ['users', user.username, 'confirm'], body: user }, callback);
+ this.request({
+ method: 'POST',
+ uri: ['users', encodeURIComponent(user.username), 'confirm'],
+ body: user
+ }, callback);
};
//
@@ -99,7 +111,11 @@ Users.prototype.forgot = function (username, params, callback) {
params = {};
}
- this.request({ method: 'POST', uri: ['users', username, 'forgot'], body: params }, callback);
+ this.request({
+ method: 'POST',
+ uri: ['users', encodeURIComponent(username), 'forgot'],
+ body: params
+ }, callback);
};
//
@@ -110,7 +126,11 @@ Users.prototype.forgot = function (username, params, callback) {
// Update user account information.
//
Users.prototype.update = function (username, object, callback) {
- this.request({ method: 'PUT', uri: ['users', username], body: object }, callback);
+ this.request({
+ method: 'PUT',
+ uri: ['users', encodeURIComponent(username)],
+ body: object
+ }, callback);
};
//
@@ -122,5 +142,8 @@ Users.prototype.update = function (username, object, callback) {
// So sad to see you go.
//
Users.prototype.destroy = function (username, callback) {
- this.request({ method: 'DELETE', uri: ['users', username] }, callback);
+ this.request({
+ method: 'DELETE',
+ uri: ['users', encodeURIComponent(username)]
+ }, callback);
};
View
@@ -1,6 +1,6 @@
{
"name": "nodejitsu-api",
- "version": "0.6.5",
+ "version": "0.6.6",
"description": "nodejitsu API client wrapper",
"keywords": ["nodejitsu", "nodejitsu-api"],
"homepage": "http://github.com/nodejitsu/nodejitsu-api",

0 comments on commit 8fb4ad5

Please sign in to comment.