utils.js 843 B

1234567891011121314151617181920212223242526272829
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. "use strict";
  5. module.metadata = {
  6. "stability": "experimental"
  7. };
  8. const { Cc, Ci, Cr } = require("chrome");
  9. const IOService = Cc["@mozilla.org/network/io-service;1"].
  10. getService(Ci.nsIIOService);
  11. const { isValidURI } = require("../url");
  12. const { method } = require("../../method/core");
  13. function newURI (uri) {
  14. if (!isValidURI(uri))
  15. throw new Error("malformed URI: " + uri);
  16. return IOService.newURI(uri, null, null);
  17. }
  18. exports.newURI = newURI;
  19. let getURL = method('sdk/url:getURL');
  20. getURL.define(String, function (url) url);
  21. getURL.define(function (object) {
  22. return null;
  23. });
  24. exports.getURL = getURL;