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

Commit

Permalink
Merge pull request #17 from samsonasik/fix-13
Browse files Browse the repository at this point in the history
Fixes #13 : reserved characters in path should be unencoded
  • Loading branch information
weierophinney committed Apr 10, 2018
2 parents 43a82de + c6fe65b commit fa7f669
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Uri.php
Expand Up @@ -1007,7 +1007,7 @@ public static function encodePath($path)
));
}

$regex = '/(?:[^' . self::CHAR_UNRESERVED . ':@&=\+\$,\/;%]+|%(?![A-Fa-f0-9]{2}))/';
$regex = '/(?:[^' . self::CHAR_UNRESERVED . ')(:@&=\+\$,\/;%]+|%(?![A-Fa-f0-9]{2}))/';
$escaper = static::getEscaper();
$replace = function ($match) use ($escaper) {
return $escaper->escapeUrl($match[0]);
Expand Down
10 changes: 10 additions & 0 deletions test/UriTest.php
Expand Up @@ -1360,4 +1360,14 @@ public function testParseTwice()
$this->assertNull($uri->getQuery());
$this->assertNull($uri->getFragment());
}

public function testReservedCharsInPathUnencoded()
{
$uri = new Uri();
$uri->setScheme('https');
$uri->setHost('api.linkedin.com');
$uri->setPath('/v1/people/~:(first-name,last-name,email-address,picture-url)');

$this->assertSame('https://api.linkedin.com/v1/people/~:(first-name,last-name,email-address,picture-url)', $uri->toString());
}
}

0 comments on commit fa7f669

Please sign in to comment.