Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not allow for multiple querystring parameters with the same name #71

Open
deremer opened this issue Sep 29, 2011 · 1 comment · May be fixed by #298
Open

Does not allow for multiple querystring parameters with the same name #71

deremer opened this issue Sep 29, 2011 · 1 comment · May be fixed by #298

Comments

@deremer
Copy link

deremer commented Sep 29, 2011

Some APIs that use this module allow the developer to pass the same querystring parameter multiple times. For instance, see SimpleGeo and categories... https://simplegeo.com/docs/api-endpoints/simplegeo-places

The oauth implementation turns querystring parameters into object, so a given parameter can only exist one time, so it changes the parameter name to be category[0], categort[1], etc.

I devised a way to fix this by modifying "exports.OAuth.prototype._normaliseRequestParams" to look like this...

exports.OAuth.prototype._normaliseRequestParams= function(arguments) {
var argument_pairs= this._makeArrayOfArgumentsHash(arguments);

// David DeRemer: added logic to allow for multiple occurrences of the same querystring parameter
for (var i=0; i<argument_pairs.length; i++) {
if (argument_pairs[i][0].search(/[\d_]/) != -1) {
argument_pairs[i] = [argument_pairs[i][0].replace(/[\d_]/,''), argument_pairs[i][1]];
}
}

// First encode them #3.4.1.3.2 .1
for(var i=0;i<argument_pairs.length;i++) {
argument_pairs[i][0]= this._encodeData( argument_pairs[i][0] );
argument_pairs[i][1]= this._encodeData( argument_pairs[i][1] );
}

// Then sort them #3.4.1.3.2 .2
argument_pairs= this._sortRequestParams( argument_pairs );

// Then concatenate together #3.4.1.3.2 .3 & .4
var args= "";
for(var i=0;i<argument_pairs.length;i++) {
args+= argument_pairs[i][0];
args+= "="
args+= argument_pairs[i][1];
if( i < argument_pairs.length-1 ) args+= "&";
}
return args;
}

You may want to consider adding something like this into the main branch.

@tchap
Copy link

tchap commented Apr 22, 2016

👍

@tchap tchap linked a pull request Apr 22, 2016 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants