I want to manipulate a URL to get just the base site name.
For example I have the URL:
http://stackoverflow.com/questions/ask,
which should just return stackoverflow.
Also if I have the URL:
http://stackoverflow.com/questions/4988199/rails-3-mechanize-socketerror-getaddrinfo-host-or-name-not-known
it should also be only stackoverflow.
Final example, if I have the URL:
http://www.google.dk/search?q=ruby+string+manipulation
it should be google.
How do I strip away everything but the domain name of a URL?