Bug 1497352 - Port Bug 1432187 [Change code to use nsIStandardURLMutator.{init,setDefaultPort}] to ChatZilla. r=gijs
authorBill Gianopoulos <wgianopoulos@gmail.com>
Tue, 11 Sep 2018 07:05:01 -0400
changeset 2125 a8e14a8352ec558b500bbb3e23c3cc17af295bd0
parent 2124 3adf399a054ec99c661d98c108b574511f42b5c2
child 2126 75c8c75015bc5afdf7930a834f599fe1c04f6eca
push id522
push userfrgrahl@gmx.net
push dateSun, 14 Oct 2018 13:39:19 +0000
reviewersgijs
bugs1497352, 1432187
Bug 1497352 - Port Bug 1432187 [Change code to use nsIStandardURLMutator.{init,setDefaultPort}] to ChatZilla. r=gijs
js/lib/protocol-handlers.jsm
--- a/js/lib/protocol-handlers.jsm
+++ b/js/lib/protocol-handlers.jsm
@@ -68,23 +68,30 @@ IRCProtocolHandler.prototype =
     allowPort(port, scheme)
     {
         // Allow all ports to connect, so long as they are irc: or ircs:
         return (scheme === 'irc' || scheme === 'ircs');
     },
 
     newURI(spec, charset, baseURI)
     {
-        const cls = Cc[STANDARDURL_CONTRACTID];
-        const url = cls.createInstance(Ci.nsIStandardURL);
         const port = this.isSecure ? 9999 : 6667;
 
-        url.init(Ci.nsIStandardURL.URLTYPE_STANDARD, port, spec, charset, baseURI);
+        if (!Cc.hasOwnProperty("@mozilla.org/network/standard-url-mutator;1")) {
+            const cls = Cc[STANDARDURL_CONTRACTID];
+            const url = cls.createInstance(Ci.nsIStandardURL);
+
+            url.init(Ci.nsIStandardURL.URLTYPE_STANDARD, port, spec, charset, baseURI);
 
-        return url.QueryInterface(Ci.nsIURI);
+            return url.QueryInterface(Ci.nsIURI);
+        }
+        return Cc["@mozilla.org/network/standard-url-mutator;1"]
+                 .createInstance(Ci.nsIStandardURLMutator)
+                 .init(Ci.nsIStandardURL.URLTYPE_STANDARD, port, spec, charset, baseURI)
+                 .finalize();
     },
 
     newChannel(URI)
     {
         const ios = Cc[IOSERVICE_CONTRACTID].getService(Ci.nsIIOService);
         if (!ios.allowPort(URI.port, URI.scheme))
             throw Cr.NS_ERROR_FAILURE;