Closed Bug 367446 Opened 18 years ago Closed 17 years ago

nsIEffectiveTLDService could use some helpers

Categories

(Core :: Networking, defect)

x86
macOS
defect
Not set
normal

Tracking

()

VERIFIED DUPLICATE of bug 368989

People

(Reporter: dcamp, Unassigned)

Details

Attachments

(1 file)

I imagine that when using the tld service people generally want either the effective tld as a string ("org"), or they want the full domain ("mozilla.org").
If you want both the effective domain and the remaining subdomains as two strings, something like getEffectiveDomainLength would be nice as well.
Comment on attachment 251996 [details] [diff] [review]
add getEffectiveTLD and getEffectiveDomain methods

GetEffectiveTLDLength can be 0, which should be handled as a special case in GetEffectiveDomain. See bug 364129.
yeah, I'll update this patch if/when the other patch is taken
Blocks: 366797
from bug 366797 comment #44:
> Turns out the effectiveTLD service takes the UTF-8 list and normalizes it on
> load. Having the data pre-normalized might save a smidgen of time for any
> non-ascii domains but is not necessary, and having the .dat file more readable
> is a win.
> 
> You also don't have to give the service punycode, it'll take IDN and normalize
> it before comparing to the domain list. But the "number of characters" answer
> will be based on the normalized string so the answer might not match the string
> you have if yours is not already normalized. A bit confusing, all the more
> reason for the string-returning helper methods I proposed.

Blocks: 367799
For my purposes, it would be exceedingly handy to be able to retrieve the ETLD+1, and I suspect that many other consumers would also find that handy.
Err, sorry, I just realized that ETLD+1 is exactly what the getEffectiveDomain method provides.
btw, here's what I doing currently to handle IDN:

> var effectiveDomain = host.split(".");
> var subdomainCount = effectiveDomain.length -
>                      asciiHost.slice(asciiHost.length -
>                                      tldService.getEffectiveTLDLength(asciiHost))
>                               .split(".").length - 1;
> if (subdomainCount > 0) {
>   var effectiveSubdomain = [];
>   while (subdomainCount--)
>     effectiveSubdomain.push(effectiveDomain.shift());
>   effectiveSubdomain = effectiveSubdomain.join(".") + ".";
> } else
>   var effectiveSubdomain = "";
> effectiveDomain = effectiveDomain.join(".");
These would still be helpful helper methods to have - and I'm reluctant to write patches which stringhack around with getEffectiveTLDLength if these helpers are on the way.  

Is there anything blocking this patch from going to review other than 0 handling (which could be added as part of bug 364129 instead of here)? 
Another patch is in bug 368989.
Dave: can you and Wladimir (bug 368989) cooperate to work out what we need to do? Note that the "+1" in ETD+1 needs to be variable (our current initial plan is to use +2, but that might change, and we want people to test with other values), so I suggest the interface should take that number as a parameter.

Gerv
duping per Dave.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → DUPLICATE
No longer blocks: 366797, 367799
V/dupe.
Status: RESOLVED → VERIFIED
QA Contact: networking → benc
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: