Skip to content

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

deremer opened this Issue Sep 29, 2011 · 1 comment

2 participants

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...

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 # .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 # .2
argument_pairs= this._sortRequestParams( argument_pairs );

// Then concatenate together # .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 commented Apr 22, 2016


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.