Permalink
Browse files

fix double slashes in paths

  • Loading branch information...
1 parent 41ca3a7 commit 20ef5d6d223b3f9f8f6d65100052815121b43c90 @moritz moritz committed Jun 14, 2011
Showing with 7 additions and 2 deletions.
  1. +2 −2 lib/LWP/Simple.pm
  2. +5 −0 t/parse-url.t
View
@@ -209,11 +209,11 @@ method parse_url (Str $url) {
my @path;
my $path;
- @path = $url.split(/\/+/);
+ @path = $url.split(/\/+/, 3);
$scheme = @path.shift;
$scheme .= chop;
$hostname = @path.shift;
- $path = '/' ~ @path.join('/');
+ $path = '/' ~ (@path[0] // '');
#say 'scheme:', $scheme;
#say 'hostname:', $hostname;
View
@@ -27,6 +27,11 @@ my @test = (
'FTP url',
'ftp://get.opera.com/pub/opera/win/1054/en/Opera_1054_en_Setup.exe',
['ftp', 'get.opera.com', 21, '/pub/opera/win/1054/en/Opera_1054_en_Setup.exe'],
+
+ 'HTTP URL with double-slashes',
+ 'http://tinyurl.com/api-create.php?url=http://digg.com',
+ ['http', 'tinyurl.com', 80, '/api-create.php?url=http://digg.com'],
+
);
for @test -> $test, $url, $results {

0 comments on commit 20ef5d6

Please sign in to comment.