Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

another encoding fix

  • Loading branch information...
commit dcf50a9ed2812c1bf034b22275682590b18a50cf 1 parent 5ad1248
@contra contra authored
Showing with 9 additions and 6 deletions.
  1. +6 −3 lib/nodester.js
  2. +1 −1  package.json
  3. +2 −2 src/nodester.coffee
View
9 lib/nodester.js
@@ -1,5 +1,5 @@
(function() {
- var Nodester, fs, handleResponse, querystring, request;
+ var Nodester, encode, fs, handleResponse, querystring, request;
request = require('request');
@@ -7,6 +7,8 @@
fs = require('fs');
+ encode = encodeURIComponent;
+
Nodester = (function() {
var user_delete;
@@ -18,13 +20,13 @@
this.secure = secure;
if ((_ref = this.basehost) == null) this.basehost = 'api.nodester.com';
this.protocol = this.secure ? 'https://' : 'http://';
- this.baseurl = "" + this.protocol + username + ":" + this.password + "@" + basehost + "/";
+ this.baseurl = "" + this.protocol + (encode(username)) + ":" + (encode(this.password)) + "@" + basehost + "/";
}
Nodester.prototype.request = function(method, path, body, cb) {
var req;
req = {
- uri: encodeURIComponent(this.baseurl + path),
+ uri: this.baseurl + encodeURI(path),
method: method,
body: querystring.stringify(body),
headers: {
@@ -32,6 +34,7 @@
},
proxy: process.env.http_proxy
};
+ if (process.env.debug != null) console.log(req);
return request(req, handleResponse(cb));
};
View
2  package.json
@@ -1,7 +1,7 @@
{
"name":"nodester-api",
"description":"A library to interact with Nodester",
- "version":"0.1.20",
+ "version":"0.1.21",
"homepage":"http://nodester.com/",
"repository":"git://github.com/nodester/nodester-api.git",
"author":"Contra <contra@nodester.com>",
View
4 src/nodester.coffee
@@ -11,13 +11,13 @@ class Nodester
request: (method, path, body, cb) ->
req =
- uri: encodeURI(@baseurl + path)
+ uri: @baseurl + encodeURI(path)
method: method
body: querystring.stringify(body)
headers:
'Content-Type': 'application/x-www-form-urlencoded'
proxy: process.env.http_proxy
-
+ console.log req if process.env.debug?
request req, handleResponse cb
get: (path, cb) -> @request "GET", path, null, cb
Please sign in to comment.
Something went wrong with that request. Please try again.