Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#3449 closed defect (fixed) messes up the order of the arguments

Reported by: guest Owned by: alex
Priority: high Milestone: 0.9beta
Component: IO Version: 0.9
Keywords: Cc: [email protected]
Blocked By: Blocking:


there's some kludge in which is used only from unfortunately this kludge messes up the order of the posted params which was causing me headaches, because i'm passing RPC arguments using the 'content' kwarg of bind. locally i've removed the kludge, please consider committing something like this into src/io/common.js: = function(/*Object*/map, /*String?*/encoding){
	// summary:
	//		Converts name/values pairs in the map object to an URL-encoded string
	//		with format of name1=value1&name2=value2...
	//		map: Object
	//			Object that has the contains the names and values.
	//		encoding: String?
	//			String to specify how to encode the name and value. If the encoding string
	//			contains "utf" (case-insensitive), then encodeURIComponent is used. Otherwise
	//			dojo.string.encodeAscii is used.
	var encoder = /utf/i.test(encoding||"") ? encodeURIComponent : dojo.string.encodeAscii;
	var mapped = [];
	var control = new Object();
	for(var name in map){
		var storeValue = function(elt){
			mapped.push(encoder(name) + "=" + encoder(elt));
			var value = map[name];
			// FIXME: should be isArrayLike?
			if (dojo.lang.isArray(value)){
				dojo.lang.forEach(value, storeValue);
	return mapped.join("&"); //String

Change History (2)

comment:1 Changed 15 years ago by James Burke

Milestone: 0.9beta
Resolution: fixed
Status: newclosed

I agree the code looks a bit odd. However, I believe you are not guaranteed a specific order when asking for property names off of an object (via for(var name in map)), so even without this odd code, I don't think you can assume an ordering to the parameters. It might work out that way in current browser-based javascript implementations, but it is not guaranteed (IIRC, it is not true in the Java-base Rhino JS engine).

In any case, I believe the weird code has been fixed in the 0.9 codebase, see dojo.objectToQuery() here:

comment:2 Changed 15 years ago by guest

i'm passing in a single array, so the order should be ok. i'll wait for 0.9 then, and use my patched version meanwhile. thanks for the info!

Note: See TracTickets for help on using tickets.