Permalink
Browse files

Fix: hardcoded "?format=json" parameter breaks parametrized paths.

Some API methods requires the first parameter to be appended with and '?' char.
When one or more parameters are added to a path (eg. /people-search?keywords=),
prepend a '&' char to the hardcoded 'format=json' string.
  • Loading branch information...
1 parent 9ba4e44 commit 76c21095cb12440d6f32f5d9855507b9283f761d @gmodena gmodena committed Oct 17, 2011
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/linkedin_client.js
View
@@ -22,7 +22,8 @@ module.exports = function (key, secret, redirect) {
, {'Accept': '*/*', 'Connection': 'close'}
)
}
-
+ , paramAppender = "?"
+ , hasParameters = /\/*\?/i
, _rest_base = 'http://api.linkedin.com/v1';
memoize[key + secret + redirect] = CLIENT;
@@ -58,9 +59,13 @@ module.exports = function (key, secret, redirect) {
if (method.toUpperCase() === 'GET') {
params.format = 'json';
+
+ if (path.match(hasParameters)) {
+ paramAppender = "&";
+ }
return CLIENT.oauth.get(
- _rest_base + path + '?' + querystring.stringify(params)
+ _rest_base + path + paramAppender + querystring.stringify(params)
, token.oauth_token
, token.oauth_token_secret
, requestCallback(callback)

0 comments on commit 76c2109

Please sign in to comment.