Skip to content

Commit 2ffca37

Browse files
[11.4] Fix double encoding of query parameters in Repositories::compare (#682)
1 parent 55cb1b2 commit 2ffca37

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/Api/Repositories.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,9 @@ public function postCommitBuildStatus($project_id, string $sha, string $state, a
413413
public function compare($project_id, string $fromShaOrMaster, string $toShaOrMaster, bool $straight = false)
414414
{
415415
$params = [
416-
'from' => self::encodePath($fromShaOrMaster),
417-
'to' => self::encodePath($toShaOrMaster),
418-
'straight' => self::encodePath($straight ? 'true' : 'false'),
416+
'from' => $fromShaOrMaster,
417+
'to' => $toShaOrMaster,
418+
'straight' => $straight ? 'true' : 'false',
419419
];
420420

421421
return $this->get($this->getProjectPath($project_id, 'repository/compare'), $params);

tests/Api/RepositoriesTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,23 @@ public function shouldNotCompareStraight(): void
541541
$this->assertEquals($expectedArray, $api->compare(1, 'master', 'feature'));
542542
}
543543

544+
/**
545+
* @test
546+
*/
547+
public function shouldCompareComplexBranchName(): void
548+
{
549+
$expectedArray = ['commit' => 'object'];
550+
551+
$api = $this->getApiMock();
552+
$api->expects($this->once())
553+
->method('get')
554+
->with('projects/1/repository/compare', ['from' => 'master', 'to' => 'feature/760.fake-branch', 'straight' => 'true'])
555+
->will($this->returnValue($expectedArray))
556+
;
557+
558+
$this->assertEquals($expectedArray, $api->compare(1, 'master', 'feature/760.fake-branch', true));
559+
}
560+
544561
/**
545562
* @test
546563
*/

0 commit comments

Comments
 (0)