It's not quite clear to me what you mean by "naked domain".  If it's just 
the last two parts of the fully qualified domain name in the given URI, 
then yes, it's trivial enough to write a function to get that yourself. 
 However, many applications are concerned with what the *registrable domain* 
is. 
 For example, from `foo.bar.baz.com` it's `baz.com` but from 
 `foo.bar.baz.co.uk` it's `baz.co.uk` (the last 3 parts, in this case!). 
 There's no algorithm for doing this correctly, but mozilla maintains the 
public suffix list that can be used for this purpose:

https://publicsuffix.org/

We wrote an Elixir library that operates on these rules which you might 
find useful:

https://github.com/seomoz/publicsuffix-elixir

Myron

On Sunday, March 26, 2017 at 2:39:06 AM UTC-7, Dmitry Rubinstein wrote:
>
> Hello!
>
>
> I want to propose some new features in URI module.
>
> First one is naked domain, which works something like this
>
> assert "http://foo.bar.baz.com"; |> URI.parse |> Map.get(:naked_domain) == 
> "baz.com"
> or
> assert "http://foo.bar.baz.com"; |> URI.naked_domain == "baz.com"
>
> And subdomain method:
>
> assert "http://foo.bar.baz.com"; |> URI.subdomain("baz.com") == "foo.bar"
> assert "http://foo.bar.baz.com"; |> URI.subdomain("bar.baz.com") == "foo"
>
> May be it can be relevant.
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/1f2a3d0b-3551-4165-bf86-fb74235ff79d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to