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

Commit fa7f669

Browse files
committed
Merge pull request #17 from samsonasik/fix-13
Fixes #13 : reserved characters in path should be unencoded
2 parents 43a82de + c6fe65b commit fa7f669

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
@@ -1360,4 +1360,14 @@ public function testParseTwice()
13601360
$this->assertNull($uri->getQuery());
13611361
$this->assertNull($uri->getFragment());
13621362
}
1363+
1364+
public function testReservedCharsInPathUnencoded()
1365+
{
1366+
$uri = new Uri();
1367+
$uri->setScheme('https');
1368+
$uri->setHost('api.linkedin.com');
1369+
$uri->setPath('/v1/people/~:(first-name,last-name,email-address,picture-url)');
1370+
1371+
$this->assertSame('https://api.linkedin.com/v1/people/~:(first-name,last-name,email-address,picture-url)', $uri->toString());
1372+
}
13631373
}

0 commit comments

Comments
 (0)