Bug 1207506 - Replace all uses of Services.io in path.js with URL;r=janx
authorEddy Bruel <ejpbruel@mozilla.com>
Fri, 04 Mar 2016 13:06:48 +0100
changeset 286643 d53f6871ec137d77e57f53fe8cf90da8afe0e671
parent 286642 c3a501635246e9e7408d3f00e2c778dedaf8e22b
child 286776 365dff9e6e1fdc49c111765fbfc6518dfc4c55ea
push id17999
push userejpbruel@mozilla.com
push dateFri, 04 Mar 2016 12:03:41 +0000
treeherderfx-team@d53f6871ec13 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanx
bugs1207506
milestone47.0a1
Bug 1207506 - Replace all uses of Services.io in path.js with URL;r=janx
devtools/shared/path.js
--- a/devtools/shared/path.js
+++ b/devtools/shared/path.js
@@ -1,38 +1,37 @@
 /* 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/. */
 
 "use strict";
 
-const Services = require("Services");
+const URL = require("URL");
 
 /*
  * Returns the directory name of the path
  */
 exports.dirname = path => {
-  return Services.io.newURI(
-    ".", null, Services.io.newURI(path, null, null)).spec;
+  return new URL(".", new URL(path)).href;
 }
 
 /*
  * Join all the arguments together and normalize the resulting URI.
  * The initial path must be an full URI with a protocol (i.e. http://).
  */
 exports.joinURI = (initialPath, ...paths) => {
-  let uri;
+  let url;
 
   try {
-    uri = Services.io.newURI(initialPath, null, null);
+    url = new URL(initialPath);
   }
   catch(e) {
     return;
   }
 
   for(let path of paths) {
     if (path) {
-      uri = Services.io.newURI(path, null, uri);
+      url = new URL(path, url);
     }
   }
 
-  return uri.spec;
+  return url.href;
 }