Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix double slashes in paths

  • Loading branch information...
commit 20ef5d6d223b3f9f8f6d65100052815121b43c90 1 parent 41ca3a7
@moritz moritz authored
Showing with 7 additions and 2 deletions.
  1. +2 −2 lib/LWP/Simple.pm
  2. +5 −0 t/parse-url.t
View
4 lib/LWP/Simple.pm
@@ -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
5 t/parse-url.t
@@ -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 {
Please sign in to comment.
Something went wrong with that request. Please try again.