Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add 'naked' or 'apex_domain' output. #54

Closed
maxwell opened this issue Jan 18, 2012 · 4 comments
Closed

add 'naked' or 'apex_domain' output. #54

maxwell opened this issue Jan 18, 2012 · 4 comments

Comments

@maxwell
Copy link

maxwell commented Jan 18, 2012

This would be a 'nice to have' feature of addressable.

http://blog.cloudflare.com/zone-apex-naked-domain-root-domain-cname-supp

(see my first comment, as I wasn't very clear when first submitting this Feature request)

@sporkmonger
Copy link
Owner

Sure... uhm, if it were possible or in any way in-scope for the library. This is something that really needs to be solved at the DNS / web server level. Addressable can't really help here.

@maxwell
Copy link
Author

maxwell commented Jan 18, 2012

Hi, sorry, I guess I was not clear enough.

For example say I have some sort of SSL requirement which requires 'www' in my url. (ie I am using EC2 or Heroku).

However, in the case that people are Webfingering my domain, these requests are going to my 'apex' domain.

a = Addressable::URI.parse('https://www.myssldomain.com')
a.authority  #=> www.myssldomain.com
a.host #=> www.myssldomain.com

#what I am trying to propose would be kind of nice

a.apex_domain #=> myssldomain.com

As you mentioned, I realize this is not hard to do by gsubing out the 'www.', but it feels dirty and something Addressable or URI should accomplish, given that Addressable has other nice to haves in the library.

@sporkmonger sporkmonger reopened this Jan 18, 2012
@sporkmonger
Copy link
Owner

Ok, I see what you mean. That's fair. Low priority at the moment though.

@sporkmonger
Copy link
Owner

Started thinking about trying to implement this today. After about 15 minutes I realized that this isn't actually possible to build correctly without rather extensive tables of TLDs and second level domains that I'm not inclined to introduce.

uri = Addressable::URI.parse('https://www.example.com/')
uri.zone_apex # => 'example.com'
uri = Addressable::URI.parse('https://www.example.co.ke/')
uri.zone_apex # => 'example.co.ke'

If it could be done with a simple regular expression, that'd be one thing, but as far as I can tell, the zone apex can exist at several different levels depending on where and how the domain was registered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants