cowboy / jquery-bbq

jQuery BBQ: Back Button & Query Library

Home Page:http://benalman.com/projects/jquery-bbq-plugin/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jQuery.param.querystring (build url) should use recursive merge (aka. deep copy).

Asgaroth opened this issue · comments

jQuery.param.querystring (build url) does not currently merge params acordinly when using array typed queryStrings

Assume an URL like this:

var url = "?Obj[attr1]=a&Obj[attr2]=b";

If we wish to merge a data object like

var data = { Obj : { attr3 : c } };

we (or me) would expect the result from jQuery.param.querystring (url, data) to be:

"?Obj[attr1]=a&Obj[attr2]=b&Obj[attr3]=c"

But instead we get:

"?Obj[attr3]=c"

This is because when calling $.extend on jquery.bb-bbq.js at line 281, simple, and not recursive, merge is used

To solve this, the line should look like:
: $.extend( true, {}, url_params, params ); // passed params override url params

which solves the issue and returns the expected url.