Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit 2cb5e12

Browse files
committed
Fixes #13 : reserved characters in path should be unencoded
1 parent bd0b25a commit 2cb5e12

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/Uri.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ public static function encodePath($path)
10071007
));
10081008
}
10091009

1010-
$regex = '/(?:[^' . self::CHAR_UNRESERVED . ':@&=\+\$,\/;%]+|%(?![A-Fa-f0-9]{2}))/';
1010+
$regex = '/(?:[^(' . self::CHAR_UNRESERVED . '):@&=\+\$,\/;%]+|%(?![A-Fa-f0-9]{2}))/';
10111011
$escaper = static::getEscaper();
10121012
$replace = function ($match) use ($escaper) {
10131013
return $escaper->escapeUrl($match[0]);

test/UriTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,4 +1346,14 @@ public function testParseTwice()
13461346
$this->assertNull($uri->getQuery());
13471347
$this->assertNull($uri->getFragment());
13481348
}
1349+
1350+
public function testReservedCharsInPathUnencoded()
1351+
{
1352+
$uri = new Uri();
1353+
$uri->setScheme('https');
1354+
$uri->setHost('api.linkedin.com');
1355+
$uri->setPath('/v1/people/~:(first-name,last-name,email-address,picture-url)');
1356+
1357+
$this->assertSame('https://api.linkedin.com/v1/people/~:(first-name,last-name,email-address,picture-url)', $uri->toString());
1358+
}
13491359
}

0 commit comments

Comments
 (0)