Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #88 from gr2m/master

workaround url encoding for q parameter in search
  • Loading branch information...
commit f5d17b80bb71eab3a2405a28046b97dc63b6bcd5 2 parents 5247e53 + 6473591
@pksunkara authored
Showing with 26 additions and 3 deletions.
  1. +13 −2 lib/octonode/client.js
  2. +13 −1 src/octonode/client.coffee
View
15 lib/octonode/client.js
@@ -98,7 +98,7 @@
};
Client.prototype.buildUrl = function(path, pageOrQuery, per_page) {
- var query;
+ var q, query, separator, _url;
if (path == null) {
path = '/';
}
@@ -125,13 +125,24 @@
query.client_id = this.token.id;
query.client_secret = this.token.secret;
}
- return url.format({
+ if (query.q) {
+ q = query.q;
+ delete query.q;
+ if (Object.keys(query).length) {
+ separator = '&';
+ } else {
+ separator = '?';
+ }
+ }
+ _url = url.format({
protocol: "https:",
auth: typeof this.token === 'object' && this.token.username ? "" + this.token.username + ":" + this.token.password : '',
hostname: this.options && this.options.hostname || "api.github.com",
pathname: path,
query: query
});
+ _url += "" + separator + "q=" + q;
+ return _url;
};
Client.prototype.errorHandle = function(res, body, callback) {
View
14 src/octonode/client.coffee
@@ -85,13 +85,25 @@ class Client
query.client_id = @token.id
query.client_secret = @token.secret
- url.format
+ # https://github.com/pksunkara/octonode/issues/87
+ if query.q
+ q = query.q
+ delete query.q
+ if Object.keys(query).length
+ separator = '&'
+ else
+ separator = '?'
+
+ _url = url.format
protocol: "https:"
auth: if typeof @token == 'object' and @token.username then "#{@token.username}:#{@token.password}" else ''
hostname: @options and @options.hostname or "api.github.com"
pathname: path
query: query
+ _url += "#{separator}q=#{q}"
+ return _url
+
errorHandle: (res, body, callback) ->
# TODO: More detailed HTTP error message
return callback(new HttpError('Error ' + res.statusCode, res.statusCode, res.headers)) if Math.floor(res.statusCode/100) is 5

1 comment on commit f5d17b8

@gr2m

would you mind to publish a new version including this fix to npm?

Please sign in to comment.
Something went wrong with that request. Please try again.