We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

Code snippets:URI parsing

When dealing with the facilities of nsIURI, the task of parsing a URI can still require additional work.

It's advised that you use the nsIEffectiveTLDService.

Grabbing the main domain using the EffectiveTLDService

Even using the ETLDService, you're unable to get just the base domain sans TLD. So, here's some sample code to determine the base domain without any suffixes:

var eTLDService = Components.classes["@mozilla.org/network/effective-tld-service;1"].
var suffix = eTLDService.getPublicSuffix(aURI);
var basedomain = eTLDService.getBaseDomain(aURI); // this includes the TLD
basedomain = basedomain.substr(0, (basedomain.length - suffix.length - 1)); // - 1 to remove the period before the tld


Document Tags and Contributors

Last updated by: Anonymous,