From: Bob Showalter Date: 2007-06-20T22:02:51+09:00 Subject: Re: Relative To Absolute Path Convertor On 6/19/07, ciocan wrote: > Is there a built in function/plugin that converts > relative paths from a html page to absolute ones? > > Example: > target url: http://mysite.com/folder/url.html > > url content: > ... > > some link > ... > > converted content: > ... > > < a href="http://mysite.com/folder/link.html">some link > ... > > How can I accomplish this using ruby ? Use URI#merge: >> require 'uri' => true >> base = URI.parse("http://mysite.com/folder/url.html") => # >> base.merge("/script.js").to_s => "http://mysite.com/script.js" >> base.merge("link.html").to_s => "http://mysite.com/folder/link.html"