Bug 1337015 - show multiple select params correctly;r=Honza
MozReview-Commit-ID: CykBya4ToeW
--- a/devtools/client/netmonitor/shared/components/params-panel.js
+++ b/devtools/client/netmonitor/shared/components/params-panel.js
@@ -58,24 +58,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