How construct nsIURI aBaseURI object?
-
- Posts: 779
- Joined: June 12th, 2008, 9:02 am
How construct nsIURI aBaseURI object?
How pass. aBaseURI parameter to newChannel2 nsIIOService?
-
- Posts: 6437
- Joined: February 3rd, 2009, 6:29 pm
Re: How construct nsIURI aBaseURI object?
If you are using the spec param, then just use null for the baseURI param.
Try these newURI(aSpec, aOriginCharset, aBaseURI) code snippets in the browser console.
The second example removes the reference portion of the url. (part after "#")
The third example uses the spec param so ignores the baseURI param.
Reference
http://searchfox.org/mozilla-release/so ... ervice.idl
http://searchfox.org/mozilla-release/so ... nsIURI.idl
Try these newURI(aSpec, aOriginCharset, aBaseURI) code snippets in the browser console.
Code: Select all
(function () {
var io = Components.classes["@mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService);
var uri = io.newURI("http://www.example.com/alpha/?beta=gamma#delta", null, null);
console.log("example 1: " + uri.spec);
console.log(uri);
})();
(function () {
var io = Components.classes["@mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService);
var baseURI = io.newURI("http://www.example.com/alpha/?beta=gamma#delta", null, null);
var uri = io.newURI(null, null, baseURI);
console.log("example 2: " + uri.spec);
console.log(uri);
})();
(function () {
var io = Components.classes["@mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService);
var baseURI = io.newURI("http://www.test.com/aaa/?bbb=ggg#ddd", null, null);
var uri = io.newURI("http://www.example.com/alpha/?beta=gamma#delta", null, baseURI);
console.log("example 3: " + uri.spec);
console.log(uri);
})();
The third example uses the spec param so ignores the baseURI param.
Reference
http://searchfox.org/mozilla-release/so ... ervice.idl
http://searchfox.org/mozilla-release/so ... nsIURI.idl
-
- Posts: 779
- Joined: June 12th, 2008, 9:02 am
Re: How construct nsIURI aBaseURI object?
When, to handle a protocol, I use
I get chrome protocol transformed to file protocol.
Do it not is possible to mantain the chrome protocol?
Code: Select all
var url="chrome://extpath/content/Email.htm?mailto=mailto:"
let ch=ios.newChannel2(url+aURI.spec.substr(aURI.spec.indexOf(":")+1), null, null, null, Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager).getSystemPrincipal(), null, Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, Ci.nsIContentPolicy.TYPE_OTHER);
Do it not is possible to mantain the chrome protocol?
-
- Posts: 6437
- Joined: February 3rd, 2009, 6:29 pm
Re: How construct nsIURI aBaseURI object?
I don't know how to mantain that.
Maybe you could convert the file url to a chrome url.
Protocol conversion example
http://forums.mozillazine.org/viewtopic ... &t=2999471
Maybe you could convert the file url to a chrome url.
Protocol conversion example
http://forums.mozillazine.org/viewtopic ... &t=2999471