Bug 1235118 - JSON Viewer: remove support for .json URL extensions; r=jryans a=sylvestre
authorJan Odvarko <odvarko@gmail.com>
Mon, 04 Jan 2016 17:31:01 +0100
changeset 310723 32512bb6e431ee8a5a7fa4fd7a22c1fc2a35ca78
parent 310722 2db713b1c2fb3de36fedf95076c27e9e8c453b84
child 310724 3418df386e3987374a287108d44e05d02bae8890
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans, sylvestre
bugs1235118
milestone45.0a2
Bug 1235118 - JSON Viewer: remove support for .json URL extensions; r=jryans a=sylvestre
devtools/client/jsonview/converter-sniffer.js
devtools/shared/webconsole/network-helper.js
--- a/devtools/client/jsonview/converter-sniffer.js
+++ b/devtools/client/jsonview/converter-sniffer.js
@@ -17,17 +17,16 @@ loader.lazyRequireGetter(this, "NetworkH
                                "devtools/shared/webconsole/network-helper");
 
 // Constants
 const JSON_TYPE = "application/json";
 const CONTRACT_ID = "@mozilla.org/devtools/jsonview-sniffer;1";
 const CLASS_ID = "{4148c488-dca1-49fc-a621-2a0097a62422}";
 const JSON_VIEW_MIME_TYPE = "application/vnd.mozilla.json.view";
 const JSON_VIEW_TYPE = "JSON View";
-const JSON_EXTENSION = "json";
 const CONTENT_SNIFFER_CATEGORY = "net-content-sniffers";
 
 /**
  * This component represents a sniffer (implements nsIContentSniffer
  * interface) responsible for changing top level 'application/json'
  * document types to: 'application/vnd.mozilla.json.view'.
  *
  * This internal type is consequently rendered by JSON View component
@@ -59,20 +58,16 @@ var Sniffer = Class({
         // Channel doesn't support content dispositions
       }
 
       // Check the response content type and if it's application/json
       // change it to new internal type consumed by JSON View.
       if (aRequest.contentType == JSON_TYPE) {
         return JSON_VIEW_MIME_TYPE;
       }
-
-      if (NetworkHelper.getFileExtension(aRequest.name) == JSON_EXTENSION) {
-        return JSON_VIEW_MIME_TYPE;
-      }
     }
 
     return "";
   }
 });
 
 var service = xpcom.Service({
   id: components.ID(CLASS_ID),
--- a/devtools/shared/webconsole/network-helper.js
+++ b/devtools/shared/webconsole/network-helper.js
@@ -798,44 +798,14 @@ var NetworkHelper = {
   nsIURL: function(aUrl, aStore = gNSURLStore) {
     if (aStore.has(aUrl)) {
       return aStore.get(aUrl);
     }
 
     let uri = Services.io.newURI(aUrl, null, null).QueryInterface(Ci.nsIURL);
     aStore.set(aUrl, uri);
     return uri;
-  },
-
-  /**
-   * Returns extension for file URLs (e.g. 'json').
-   * Not everyURL has an extension and this method works as follows:
-   * 1) Remove query string
-   * 2) Get part after the last slash (a file name)
-   * 3) Look for the last dot (an extension)
-   */
-  getFileExtension: function(aUrl) {
-    if (!aUrl) {
-      return;
-    }
-
-    // Remove query string from the URL if any.
-    let queryString = aUrl.indexOf("?");
-    if (queryString != -1) {
-      aUrl = aUrl.substr(0, queryString);
-    }
-
-    // Look for the part after last slash
-    var lastSlash = aUrl.lastIndexOf("/");
-    var fileName = aUrl.substr(lastSlash + 1);
-    if (!fileName) {
-      return;
-    }
-
-    // Now get the file extension.
-    var lastDot = fileName.lastIndexOf(".");
-    return fileName.substr(lastDot + 1);
   }
 };
 
 for (let prop of Object.getOwnPropertyNames(NetworkHelper)) {
   exports[prop] = NetworkHelper[prop];
 }