Closed Bug 861084 Opened 12 years ago Closed 12 years ago

add tld property to URL

Categories

(Add-on SDK Graveyard :: General, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: evold, Assigned: jsantell)

References

Details

(Whiteboard: [good first bug])

Add a top level domain property to URL instances, or a method that will extract it to sdk/url.
also a suffix property
Assignee: nobody → jsantell
Flags: needinfo?(rFobic)
Erik are you talking about equivalent of `hostname` property or `origin` property from `window.location` ? I think in general I'm +1 on making our URL instances be compatible with `window.location`.
Flags: needinfo?(rFobic)
Can we get a use case for this?
Flags: needinfo?(evold)
In Scriptish I can match all top level domains for xyz with `@include http://xyz.tld/*` which will match xyz.com or xyz.ca for xyz.co.uk. I do this by getting the tld and replacing that with '.tld' then testing that against the regexp produced from @include. Another case is for my no-ga add-on, I want to block any google-analyics.tld.
Flags: needinfo?(evold)
OS: Mac OS X → All
Hardware: x86 → All
(In reply to Irakli Gozilalishvili [:irakli] [:gozala] [@gozala] from comment #2) > Erik are you talking about equivalent of `hostname` property or `origin` > property from `window.location` ? I think in general I'm +1 on making our > URL instances be > compatible with `window.location`. That makes sense too, just made bug 864658 for that.
Whiteboard: [good first bug]
Flags: needinfo?(rFobic)
Erik won't this `http://xyz.*/*` cover this use case ? Also include can take a plain regexp too, to be even more specific. I think I'd rather see such functions in the user space rather than core itself.
Flags: needinfo?(rFobic)
(In reply to Irakli Gozilalishvili [:irakli] [:gozala] [@gozala] from comment #6) > Erik won't this `http://xyz.*/*` cover this use case ? No, xyz could merely be a subdomain name. > Also include can take a plain regexp too, to be even more specific. Still not good enough, tld names don't follow a pattern, they are somewhat arbitrary. For instance co.uk is a tld, and x.y.z could be, so they dividing line between tld and domain name is tricky to find, a reg exp cannot do that. > I think I'd rather see such functions in the user space rather than core > itself. Most in the wild implementations, use a resource like https://github.com/masylum/tldextract/blob/master/lib/tldextract.js uses http://mxr.mozilla.org/mozilla/source/netwerk/dns/src/effective_tld_names.dat?raw=1 (or god forbid their own list..) which I assume https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIEffectiveTLDService is using somehow.. and it's a file that could move around. We should be exposing the tld that the browser understands and not another imo.
Flags: needinfo?(evold)
Flags: needinfo?(rFobic)
Also we shouldn't reinvent the wheel.
Erik, I think we're off track here. As I mentioned earlier I have no problem with exposing some function like collisions `getDomain(url)`. Which is very different from extending MatchPattern that page-mod uses. If you do want to extend later as well, let's have a separate discussion about it, in some place else.
Flags: needinfo?(rFobic)
(In reply to Irakli Gozilalishvili [:irakli] [:gozala] [@gozala] from comment #10) > Erik, I think we're off track here. As I mentioned earlier I have no problem > with exposing some function like collisions `getDomain(url)`. Which is very > different from extending MatchPattern that page-mod uses. > > If you do want to extend later as well, let's have a separate discussion > about it, in some place else. Yeah I think we are off track. I merely want to add some way to get the tld for a url to the sdk, I have no preference where that api is. I see no need to extend the match pattern module.
We can use the Mozilla TLD list, but there are many more TLDs coming in the future, and wonder how up to date this'll be.. and that seems like the only reliable way. Because of the ever-changing acceptable TLDs, would it be possible to have http://xyz.* http://*.xyz.* And while it could incorrectly detect a subdomain, I'd imagine it'd be pretty slim depending on the domain (don't think you'll get too many subdomains with the name google-analytics)
Added `getTLD()` in `sdk/url` in bug 864658, fixing this issue
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Depends on: 875812
You need to log in before you can comment on or make changes to this bug.