If I had an URL:
http://www.example.com/page
I would like to interpret that to:
example.com
But, if I had:
http://blog.example.com/page
I’d like to get back:
blog.example.com
Is that difficult?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use Ruby’s URI module:
In both cases, URI extracts the whole host name, because selectively stripping the host from the domain makes no sense.
You’ll have to implement that logic separately, using something like:
Which outputs: