Over a million developers have joined DZone.

Splitting/Joining URLs

·
File.dirname "http://foo.com/bar/stuff.html"
#=> "http://foo.com/bar"

File.basename "http://foo.com/bar/stuff.html"
#=> "stuff.html"

File.split "http://foo.com/bar/stuff.html"
#=> ["http://foo.com/bar", "stuff.html"]

File.join( File.dirname("http://foo.com/bar/doc.html"), "relative_link.html" )
# => "http://foo.com/bar/relative_link.html"

(Originally by Ilmari Heikkinen on the ruby-talk mailing list.)
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}