Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the WWW-Mechanize CPAN distribution.

Report information
The Basics
Id: 9126
Status: rejected
Priority: 0/
Queue: WWW-Mechanize

People
Owner: andy [...] petdance.com
Requestors: juanmarcosmoren [...] terra.es
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: make $mech->find_link() return absolute links
When doing something like: my @download_urls = $agent->find_all_links(); foreach my $download_url (@download_urls) { $res = $agent->get( $download_url ); } Doesn't work because the links are relative. Shouldn't always them be absolute, like browsers do when you copy a link? I don't know why anyone would like relative links. At least "$res = $agent->get( $download_url );" should work with relative links.
Date: Fri, 24 Dec 2004 10:43:52 -0500
From: Mark Stosberg <mark [...] summersault.com>
To: Guest via RT <bug-WWW-Mechanize [...] rt.cpan.org>
Subject: Re: [cpan #9126] make $mech->find_link() return absolute links
RT-Send-Cc:
On Fri, Dec 24, 2004 at 08:51:56AM -0500, Guest via RT wrote: Show quoted text
> > This message about WWW-Mechanize was sent to you by guest <> via rt.cpan.org > > Full context and any attached attachments can be found at: > <URL: https://rt.cpan.org/Ticket/Display.html?id=9126 > > > When doing something like: > my @download_urls = $agent->find_all_links(); > foreach my $download_url (@download_urls) { > $res = $agent->get( $download_url ); > } > > Doesn't work because the links are relative. > Shouldn't always them be absolute, like browsers do when you copy a link? > I don't know why anyone would like relative links.
This is a reasonable suggestion. I don't see many drawbacks to this. Show quoted text
> At least "$res = $agent->get( $download_url );" should work with relative links.
I think it does if you do this: my @download_urls = $agent->find_all_links(); foreach my $download_url (@download_urls) { $res = $agent->get( $download_url ); # You have to back to be relative to the right place. $agent->back(); } Mark
From: juanmarcosmoren [...] terra.es
[mark@summersault.com - Fri Dec 24 11:06:59 2004]: Show quoted text
> > At least "$res = $agent->get( $download_url );" should work with
> relative links. > > I think it does if you do this: > > my @download_urls = $agent->find_all_links(); > foreach my $download_url (@download_urls) { > $res = $agent->get( $download_url ); > # You have to back to be relative to the right place. > $agent->back(); > }
I couldn't get it working even for the first URL, could you?
[guest - Fri Dec 24 11:38:56 2004]: Show quoted text
> [mark@summersault.com - Fri Dec 24 11:06:59 2004]:
> > > At least "$res = $agent->get( $download_url );" should work with
> > relative links. > > > > I think it does if you do this: > > > > my @download_urls = $agent->find_all_links(); > > foreach my $download_url (@download_urls) { > > $res = $agent->get( $download_url ); > > # You have to back to be relative to the right place. > > $agent->back(); > > }
> > I couldn't get it working even for the first URL, could you?
According to our test suite, things are working. If you think have found a bug, please submit a test case that illutrates it, preferably using Test::More. If the first link isn't working, that's a bug.
From: juanmarcosmoren [...] terra.es
[MARKSTOS - Sat Dec 25 15:36:52 2004]: Show quoted text
> According to our test suite, things are working. If you think have found > a bug, please submit a test case that illutrates it, preferably using > Test::More. > > If the first link isn't working, that's a bug.
Where in the test suite there's a ->get() using a relative WWW::Mechanize::Link?
From: juanmarcosmoren [...] terra.es
Maybe this is the correct fix. At least it works for me.
--- WWW/Mechanize.pm +++ WWW/Mechanize.pm @@ -313,7 +313,7 @@ my $self = shift; my $uri = shift; - $uri = $uri->url if ref($uri) eq 'WWW::Mechanize::Link'; + $uri = $uri->url_abs if ref($uri) eq 'WWW::Mechanize::Link'; $uri = $self->base ? URI->new_abs( $uri, $self->base )
Date: Sat, 25 Dec 2004 20:01:21 -0500
From: Mark Stosberg <mark [...] summersault.com>
To: Guest via RT <bug-WWW-Mechanize [...] rt.cpan.org>
Subject: Re: [cpan #9126] make $mech->find_link() return absolute links
RT-Send-Cc:
On Sat, Dec 25, 2004 at 06:06:40PM -0500, Guest via RT wrote: Show quoted text
> > This message about WWW-Mechanize was sent to you by guest <> via rt.cpan.org > > Full context and any attached attachments can be found at: > <URL: https://rt.cpan.org/Ticket/Display.html?id=9126 > > > Maybe this is the correct fix. > At least it works for me.
Thanks. I'll look into this further. And happy holidays. :) Mark
From: juanmarcosmoren [...] terra.es
[mark@summersault.com - Sat Dec 25 20:01:53 2004]: Show quoted text
> I'll look into this further.
Did someone take a look into this? I really think this should be fixed, don't you?
Show quoted text
> Did someone take a look into this? > I really think this should be fixed, don't you?
"Fix" is such a loaded word. You can use the $link->url_abs() method to get the absolute URL for whatever links you get back.
[PETDANCE - Sat Feb 12 20:56:50 2005]: Show quoted text
> "Fix" is such a loaded word. > > You can use the $link->url_abs() method to get the absolute URL for > whatever links you get back.
Don't you think that my first test case should work? Making it work, won't break anything and would make WWW::Mechanize user's life much easier. my @download_urls = $agent->find_all_links(); foreach my $download_url (@download_urls) { $res = $agent->get( $download_url ); }
Show quoted text
> Don't you think that my first test case should work? > Making it work, won't break anything and would make WWW::Mechanize > user's life much easier.
Mech needs to return the URL as it appears in the page. Links are relative to the page they appear on, and I have no intention of changing the way it Mech handles that fact.
From: juanmarcosmoren [...] terra.es
[PETDANCE - Sun Feb 13 16:59:20 2005]: Show quoted text
> > Don't you think that my first test case should work? > > Making it work, won't break anything and would make WWW::Mechanize > > user's life much easier.
> > Mech needs to return the URL as it appears in the page. Links are > relative to the page they appear on, and I have no intention of changing > the way it Mech handles that fact.
Sure, Mech needs to return the URL as it appears in the page, but I was referring to having $mech->get() accepting relative links instead of giving an unuseful error.