I'm looking for a method to reliably extract the host name from a URL string in Ruby.
e.g. http://www.mglenn.com/directory = www.mglenn.com OR http://www.mglenn.com?param=x = www.mglenn.com
I'm looking for a method to reliably extract the host name from a URL string in Ruby.
e.g. http://www.mglenn.com/directory = www.mglenn.com OR http://www.mglenn.com?param=x = www.mglenn.com
You could try something like this:
require 'uri'
myUri = URI.parse( 'http://www.mglenn.com/directory' )
print myUri.host