He missed an opportunity to make that even shorter and even more of a clusterfuck.
I present to you:
function compress(data){
var s = {}, q = [];
data.replace(/([^=&]+)=([^&]*)/g, function(m, k, v) {
s[k] ? q[s[k] - 1] += "," + v : s[k] = q.push(m);
});
return q.join("&");
}