Bug 1337015 - Show multiple select params correctly. r=Honza, a=lizzard
authorFred Lin <gasolin@mozilla.com>
Wed, 08 Feb 2017 16:57:20 +0800
changeset 378515 232dd77a7c38f8524f64356d1c43b7ff31c7488c
parent 378514 c589ef7d5db52fe5de13e0a2d905f5c69ca18d48
child 378516 a9c518127961735cd8ea777537b07c6b79335152
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza, lizzard
bugs1337015
milestone53.0a2
Bug 1337015 - Show multiple select params correctly. r=Honza, a=lizzard MozReview-Commit-ID: CykBya4ToeW
devtools/client/netmonitor/shared/components/params-panel.js
--- a/devtools/client/netmonitor/shared/components/params-panel.js
+++ b/devtools/client/netmonitor/shared/components/params-panel.js
@@ -54,24 +54,35 @@ function ParamsPanel({
   // Query String section
   if (query) {
     object[PARAMS_QUERY_STRING] =
       parseQueryString(query)
         .reduce((acc, { name, value }) =>
           name ? Object.assign(acc, { [name]: value }) : acc
         , {});
   }
+
   // Form Data section
   if (formDataSections && formDataSections.length > 0) {
     let sections = formDataSections.filter((str) => /\S/.test(str)).join("&");
     object[PARAMS_FORM_DATA] =
       parseQueryString(sections)
-        .reduce((acc, { name, value }) =>
-          name ? Object.assign(acc, { [name]: value }) : acc
-        , {});
+        .reduce((map, obj) => {
+          let value = map[obj.name];
+          // Deal with duplicate key case (ex: multiple selection)
+          if (value) {
+            if (typeof value !== "object") {
+              map[obj.name] = [value];
+            }
+            map[obj.name].push(obj.value);
+          } else {
+            map[obj.name] = obj.value;
+          }
+          return map;
+        }, {});
   }
 
   // Request payload section
   if (formDataSections && formDataSections.length === 0 && postData) {
     try {
       json = JSON.parse(postData);
     } catch (error) {
       // Continue regardless of parsing error