Link to home
Start Free TrialLog in
Avatar of TonyJix
TonyJix

asked on

Absolutizing urls..

Hi people,

I am trying to absolutize all urls.. but there is a prob. See example:

use URI::URL;

$url = "http://www.google.com/test";

I then put all links on $url, in an array: @pages. (i.e: all <a href="file.html"> tags)
So @pages = ("test.html","hi.html");

Then I try to absolutize all urls by doing:

@pages = map { $_ = url($_, $url)->abs; } @pages;

Then I print them by doing: print join("\n",@pages);

Then it gives:

http://www.google.com/test.html
http://www.google.com/hi.html

But.. it should have given:

http://www.google.com/test/test.html
http://www.google.com/test/hi.html

Any ideas?
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes the trailing slash matters...