Hi,
Whilst porting some perl code which uses the URI module:
# convert a relative url to an absolute url
my $val = "../some/relative/url.html";
my $target_url = "http://www.somehost.net/blah/page.html";
my $uri = URI->new_abs($val, $target_url);
# $uri is 'http://www.somehost.net/some/relative/url.html'
- I discovered that there seems to be no standard library equivalent in ruby, i.e. for converting relative URIs to absolute ones... or am I just not looking in the right places? (I looked on Google, ruby-doc.org, in 'Pickaxe', etc.)
Thanks,
Nick
···
___________________________________________________________ How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com
URI does this
$ irb
irb(main):001:0> require 'uri'
=> true
irb(main):002:0> original_uri = URI.parse "http://www.somehost.net/blah/page.html"
=> #<URI::HTTP:0x19999c URL:http://www.somehost.net/blah/page.html>
irb(main):003:0> puts original_uri + "../some/relative/url.html"
http://www.somehost.net/some/relative/url.html
=> nil
···
On 29 Jun 2005, at 18:05, Nick Woolley wrote:
Hi,
Whilst porting some perl code which uses the URI module:
# convert a relative url to an absolute url
my $val = "../some/relative/url.html";
my $target_url = "http://www.somehost.net/blah/page.html";
my $uri = URI->new_abs($val, $target_url);
# $uri is 'http://www.somehost.net/some/relative/url.html'
- I discovered that there seems to be no standard library equivalent in ruby, i.e. for converting relative URIs to absolute ones... or am I just not looking in the right places? (I looked on Google, ruby-doc.org, in 'Pickaxe', etc.)
--
Eric Hodel - drbrain@segment7.net - http://segment7.net
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04