diff --git a/netwerk/base/nsNetUtil.cpp b/netwerk/base/nsNetUtil.cpp index ad0bc129ea23..e345e3363803 100644 --- a/netwerk/base/nsNetUtil.cpp +++ b/netwerk/base/nsNetUtil.cpp @@ -1861,6 +1861,10 @@ nsresult NS_NewURI(nsIURI** aURI, const nsACString& aSpec, .Finalize(aURI); } + if (scheme.EqualsLiteral("dweb") || scheme.EqualsLiteral("dat")) { + return NewStandardURI(aSpec, aCharset, aBaseURI, -1, aURI); + } + #if defined(MOZ_THUNDERBIRD) || defined(MOZ_SUITE) rv = NS_NewMailnewsURI(aURI, aSpec, aCharset, aBaseURI, aIOService); if (rv != NS_ERROR_UNKNOWN_PROTOCOL) { diff --git a/netwerk/test/unit/test_URIs.js b/netwerk/test/unit/test_URIs.js index f59ba0f45bec..e61e168730db 100644 --- a/netwerk/test/unit/test_URIs.js +++ b/netwerk/test/unit/test_URIs.js @@ -639,6 +639,15 @@ function check_resolve() { Assert.equal(uri.spec, "tel::+371 27028456"); } +function test_extra_protocols() { + let url = gIoService.newURI("dweb://example.com/test"); + Assert.equal(url.host, "example.com"); + url = gIoService.newURI("dat://41f8a987cfeba80a037e51cc8357d513b62514de36f2f9b3d3eeec7a8fb3b5a5/"); + Assert.equal(url.host, "41f8a987cfeba80a037e51cc8357d513b62514de36f2f9b3d3eeec7a8fb3b5a5"); + url = gIoService.newURI("dat://example.com/test"); + Assert.equal(url.host, "example.com"); +} + // TEST MAIN FUNCTION // ------------------ function run_test() @@ -648,6 +657,7 @@ function run_test() check_schemeIsNull(); check_mozextension_query(); check_resolve(); + test_extra_protocols(); // UTF-8 check - From bug 622981 // ASCII