David 天宇 Wong
David 天宇 Wong

Reputation: 4197

javascript firefox sdk: get domain without subdomain

what is an easy way to get the domain without the subdomain.

For example in this URL: http://a.b.hllo.co.uk I want to retrieve hllo

Upvotes: 1

Views: 88

Answers (2)

the8472
the8472

Reputation: 43052

You will want to use the nsIEffectiveTLDService for this. It's basically a giant list of special-cases maintained by mozilla such as the mentioned .co.uk domain and used for same-basedomain (as opposed same-origin) policies such as cookies.

Some of its functionality is also exposed in the sdk/url module.

Upvotes: 2

Noitidart
Noitidart

Reputation: 37238

This is what you can get enter image description here

So you have to just do string manipulation on that one I would think. Does'nt look like it auotmatically gets it, but i could be wrong.

Upvotes: 1

Related Questions