How to get an absolute address of a link

Is there some URL lib that I can use to get the absolute address of a
relative URL ? Maybe I could pass a "base" link to the method . Ideally
, I would like to know if this could by achieved from mechanize , but
anything would do .
I wrote my own a while back , and I'm using it , but I would like to
know if something already exists .

···

--
Posted via http://www.ruby-forum.com/.

You can use URI.join

irb -ruri
irb(main):001:0> URI.join('http://example.com', '/path/a/b')
=> #<URI::HTTP:0xb7ce2b08 URL:http://example.com/path/a/b&gt;
irb(main):002:0> URI.join('http://example.com', 'http://google.com/path/a/b&#39;\)
=> #<URI::HTTP:0xb7cdf28c URL:http://google.com/path/a/b&gt;
irb(main):003:0>

···

On Wed, Jan 28, 2009 at 9:30 AM, Tsunami Script <lyon2003@lycos.com> wrote:

Is there some URL lib that I can use to get the absolute address of a
relative URL ? Maybe I could pass a "base" link to the method . Ideally
, I would like to know if this could by achieved from mechanize , but
anything would do .

--
Luis Parravicini
http://ktulu.com.ar/blog/

Very nice ! Thanks ! I was wondering if it would handle joins with
arguments like

arg1 = "http://site.com"
arg2 = "index.html"

or arg1 = "http://site.com/"
   arg2 = "/index.html"

and it seems to work great . Thank you !

···

--
Posted via http://www.ruby-forum.com/.