Bug 1327756 - Netmonitor divides js files into 2 groups when I sort by type. r?honza
MozReview-Commit-ID: EuuCBXyhYvr
--- a/devtools/client/netmonitor/src/components/request-list-item.js
+++ b/devtools/client/netmonitor/src/components/request-list-item.js
@@ -391,39 +391,32 @@ const CauseColumn = createFactory(create
onClick: onCauseBadgeClick,
}, "JS"),
span({ className: "subitem-label" }, causeType),
)
);
}
}));
-const CONTENT_MIME_TYPE_ABBREVIATIONS = {
- "ecmascript": "js",
- "javascript": "js",
- "x-javascript": "js"
-};
-
const TypeColumn = createFactory(createClass({
displayName: "TypeColumn",
propTypes: {
item: PropTypes.object.isRequired,
},
shouldComponentUpdate(nextProps) {
return this.props.item.mimeType !== nextProps.item.mimeType;
},
render() {
const { mimeType } = this.props.item;
let abbrevType;
if (mimeType) {
abbrevType = getAbbreviatedMimeType(mimeType);
- abbrevType = CONTENT_MIME_TYPE_ABBREVIATIONS[abbrevType] || abbrevType;
}
return (
div({
className: "requests-list-subitem requests-list-type",
title: mimeType,
},
span({ className: "subitem-label" }, abbrevType),
--- a/devtools/client/netmonitor/src/utils/request-utils.js
+++ b/devtools/client/netmonitor/src/utils/request-utils.js
@@ -1,16 +1,22 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint-disable mozilla/reject-some-requires */
"use strict";
+const CONTENT_MIME_TYPE_ABBREVIATIONS = {
+ "ecmascript": "js",
+ "javascript": "js",
+ "x-javascript": "js"
+};
+
/**
* Extracts any urlencoded form data sections (e.g. "?foo=bar&baz=42") from a
* POST request.
*
* @param {object} headers - the "requestHeaders".
* @param {object} uploadHeaders - the "requestHeadersFromUploadStream".
* @param {object} postData - the "requestPostData".
* @return {array} a promise list that is resolved with the extracted form data.
@@ -107,17 +113,18 @@ function decodeUnicodeUrl(string) {
*
* @param {string} mimeType - mime type
* @return {string} abbreviated mime type
*/
function getAbbreviatedMimeType(mimeType) {
if (!mimeType) {
return "";
}
- return (mimeType.split(";")[0].split("/")[1] || "").split("+")[0];
+ let abbrevType = (mimeType.split(";")[0].split("/")[1] || "").split("+")[0];
+ return CONTENT_MIME_TYPE_ABBREVIATIONS[abbrevType] || abbrevType;
}
/**
* Helpers for getting the last portion of a url.
* For example helper returns "basename" from http://domain.com/path/basename
* If basename portion is empty, it returns the url pathname.
*
* @param {string} url - url string