Closed
Bug 861084
Opened 12 years ago
Closed 12 years ago
add tld property to URL
Categories
(Add-on SDK Graveyard :: General, defect, P3)
Add-on SDK Graveyard
General
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.
Reporter | ||
Comment 1•12 years ago
|
||
also a suffix property
Assignee | ||
Updated•12 years ago
|
Assignee: nobody → jsantell
Reporter | ||
Updated•12 years ago
|
Flags: needinfo?(rFobic)
Comment 2•12 years ago
|
||
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)
Reporter | ||
Comment 4•12 years ago
|
||
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
Reporter | ||
Comment 5•12 years ago
|
||
(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.
Reporter | ||
Updated•12 years ago
|
Whiteboard: [good first bug]
Reporter | ||
Updated•12 years ago
|
Flags: needinfo?(rFobic)
Comment 6•12 years ago
|
||
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)
Flags: needinfo?(evold)
Reporter | ||
Comment 7•12 years ago
|
||
(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)
Reporter | ||
Updated•12 years ago
|
Flags: needinfo?(rFobic)
Reporter | ||
Comment 8•12 years ago
|
||
Also we shouldn't reinvent the wheel.
Reporter | ||
Comment 9•12 years ago
|
||
Collusion needs this too https://github.com/mozilla/collusion/blob/c2_fresh_start/lib/connection.js#L103-L112
Comment 10•12 years ago
|
||
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)
Reporter | ||
Comment 11•12 years ago
|
||
(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.
Priority: -- → P3
Assignee | ||
Comment 12•12 years ago
|
||
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)
Assignee | ||
Comment 13•12 years ago
|
||
Added `getTLD()` in `sdk/url` in bug 864658, fixing this issue
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•