Bug 1266844 - use URL, not nsIURL, in css-logic.js; r?pbro draft
authorTom Tromey <tom@tromey.com>
Fri, 24 Jun 2016 13:55:55 -0600
changeset 381215 7e3843f7a1bae416f8311cc4d6c9ac0fa41cb1b3
parent 381164 cd3866501f1fa0d058ce5b6b79fdb46b9478b554
child 523923 991ce2990a519e1322c4a135f2c36ef8b74b8f4e
push id21435
push userbmo:ttromey@mozilla.com
push dateFri, 24 Jun 2016 20:01:05 +0000
reviewerspbro
bugs1266844
milestone50.0a1
Bug 1266844 - use URL, not nsIURL, in css-logic.js; r?pbro MozReview-Commit-ID: F8eBQEJZkv7
devtools/shared/inspector/css-logic.js
--- a/devtools/shared/inspector/css-logic.js
+++ b/devtools/shared/inspector/css-logic.js
@@ -107,28 +107,27 @@ exports.shortSource = function (sheet) {
   // Use a string like "inline" if there is no source href
   if (!sheet || !sheet.href) {
     return exports.l10n("rule.sourceInline");
   }
 
   // We try, in turn, the filename, filePath, query string, whole thing
   let url = {};
   try {
-    url = Services.io.newURI(sheet.href, null, null);
-    url = url.QueryInterface(Ci.nsIURL);
+    url = new URL(sheet.href);
   } catch (ex) {
     // Some UA-provided stylesheets are not valid URLs.
   }
 
-  if (url.fileName) {
-    return url.fileName;
-  }
-
-  if (url.filePath) {
-    return url.filePath;
+  if (url.pathname) {
+    let index = url.pathname.lastIndexOf("/");
+    if (index !== -1 && index < url.pathname.length) {
+      return url.pathname.slice(index + 1);
+    }
+    return url.pathname;
   }
 
   if (url.query) {
     return url.query;
   }
 
   let dataUrl = sheet.href.match(/^(data:[^,]*),/);
   return dataUrl ? dataUrl[1] : sheet.href;