Opened 3 years ago

Closed 3 years ago

#18795 closed defect (fixed)

dojo/request array query parameter encoding

Reported by: gerhard presser Owned by: dylan
Priority: undecided Milestone: 1.11
Component: Data Version: 1.11.0-rc1
Keywords: Cc:
Blocked By: Blocking:

Description

in dojo 1.10 an array query parameter was encoded using array.toString(), this has been changed in 1.11

query: {param:["1","2","3"]}

1.10: url?param=1,2,3
1.11: url?param=1&param=2&param=3

I'm aware this matches the store-behavior - I just wanted to know if the change was intended.

Change History (6)

comment:1 Changed 3 years ago by dylan

Milestone: tbd1.11
Status: newpending

I'm not quickly finding the commit that may have led to this change (looked quickly over the past 2 years of commits, in particular at https://github.com/dojo/dojo/commits/d40757e56483d8ed177c938c433bfaf7805303a8/io-query.js ), but I'm assuming the current behavior is what I would have expected and what is documented at https://github.com/dojo/dojo/blob/d40757e56483d8ed177c938c433bfaf7805303a8/io-query.js#L29

And as far as I can tell, it behaved this way in 1.10.4 also, see https://jsfiddle.net/dylan/c2zfomrv/

comment:2 Changed 3 years ago by gerhard presser

Status: pendingnew

code:

define(["dojo/request"],function(request){

var ids = ["new","edit","delete"];

request.get("myserverurl",{
	handleAs:"json",
	query:{
		actions:ids
	}
}).then(function(result) {
//something
});
});

request, chrome-dev-tool, dojo 1.10.4
http://localhost/myserverurl?actions=%2Cnew%2Cedit%2Cdelete

request, chrome-dev-tool, dojo 1.11.0-rc1
http://localhost/myserverurl?actions=new&actions=edit&actions=delete

comment:3 Changed 3 years ago by dylan

Ok, I confirm the change based on your example, I just don't yet see what caused it. Looking at https://github.com/dojo/dojo/commits/master/request/util.js , there's nothing in there that should have led to this change, and it's just calling io-query.

comment:4 Changed 3 years ago by dylan

Status: newpending

Actually, I take that back, if I try the above example in 1.10.4 or 1.9.7, I get the same as I do with 1.11.0-rc1.

https://jsfiddle.net/dylan/mb54tc6x/

https://www.dropbox.com/s/65kmghntagxai8h/Screenshot%202016-02-26%2004.47.42.png?dl=0

comment:5 Changed 3 years ago by gerhard presser

Status: pendingnew

first I was confused, because I couldn't reproduce it in the standalone test-suite too.
but when called from the application-code, the behavior differed between 1.10 and 1.11

then I realized one big difference - in my application, multiple iframes are involved. and the array containing the strings is constructed in one frame, and then passed to another one.

and the thing that actually changed from 1.10 to 1.11 is the dojo/_base/lang.isArray() implementation - it can now handle this crazy situation.

so yeah - all problems solved - or better - explained.
sorry for bothering you

comment:6 Changed 3 years ago by dylan

Resolution: fixed
Status: newclosed

Ok, thanks, yes, that makes sense. I'm going to close this as the fix is as intended then.

Note: See TracTickets for help on using tickets.