Bug 1207506 - Replace all uses of Services.io in path.js with URL;r=janx

This commit is contained in:
Eddy Bruel 2016-03-04 13:06:48 +01:00
parent 6613c02e64
commit 1bbc0e2817

View File

@ -4,14 +4,13 @@
"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;
}
/*
@ -19,10 +18,10 @@ exports.dirname = path => {
* 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;
@ -30,9 +29,9 @@ exports.joinURI = (initialPath, ...paths) => {
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;
}