Compactify the query string Introduction
Just on Hacker news, John Resig contemplates
transforming a query “foo=1&amp;foo=2&amp;foo=3&amp;blah=a&amp;blah=b” into one that looks like this: “foo=1,2,3&amp;blah=a,b&quot;, https://johnresig.com/blog/search-and-dont-replace/.
He claims &quot;being 10 lines shorter than Mark’s solution&quot;.
Query strings consist of sequences of name-value pairs. Name-value pairs consist of a name and value, separated by =. names and values are possibly empty sequences of alphanumeric characters.
Name-value pairs are separated by the &amp; character in the sequence. Values are unique for each name.
Challenge
10 lines shorter than Mark's solution is not enough.

Read a query string.
Combine name value pairs with equal name into a single name value pair, with values concatenated and separated by comma.
Output the combined query string, with name-value pairs in the order the names are found from left to right in the query string.

This is code golf, the standard loopholes are closed.
Example Input and Output
Input:

foo=1&amp;foo=&amp;blah=a&amp;foo=3&amp;bar=x&amp;blah=b&amp;=1&amp;=2

Output:

foo=1,,3&amp;blah=a,b&amp;bar=x&amp;=1,2

Input:

foo=bar&amp;foo=foo

Output:

foo=bar,foo
JavaScript (ES6),  103 99 87  86 bytes
Saved 1 byte thanks to @MatthewJensen

s=&gt;Object.values(o=/(\w*=)(\w*)/g,s.replace(o,(s,k,v)=&gt;o[k]=o[k]?o[k]+[,v]:s)).join`&amp;`

Try it online!
Commented
s =&gt;                  // s = query string
  Object.values(      // get the values of ...
    o =               //   ... the object of this regular expression, which is
      /(\w*=)(\w*)/g, //   re-used to store the keys and values of the query
    s.replace(        //   match each key with the '=' sign and the corresponding
      o,              //   value, using the regular expression defined above
      (s, k, v) =&gt;    //   for each matched string s, key k and value v:
        o[k] =        //     update o[k]:
          o[k] ?      //       if it's already defined:
            o[k] +    //         get the current value
            [, v]     //         append a comma, followed by v
          :           //       else:
            s         //         set it to the entire matched string
                      //         (key, '=', first value)
    )                 //   end of replace()
  ).join`&amp;`           // end of Object.values(); join with '&amp;'