Skip to content

Commit b9a862c

Browse files
committed
Merge remote-tracking branch 'origin/master' into 2.x
2 parents d838a40 + efe327f commit b9a862c

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
### Removed
1111
- Deprecated option `debug_plugins` has been removed from `PluginClient`
1212

13-
## 1.8.2 (unreleased)
13+
## 1.8.2 - 2018-12-14
1414

1515
### Changed
1616

1717
- When multiple cookies exist, a single header with all cookies is sent as per RFC 6265 Section 5.4
18+
- AddPathPlugin will now trim of ending slashes in paths
1819

1920
## 1.8.1 - 2018-10-09
2021

spec/Plugin/AddPathPluginSpec.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,24 @@ public function it_adds_path(
4646
$this->handleRequest($request, PluginStub::next(), function () {});
4747
}
4848

49-
public function it_throws_exception_on_trailing_slash(UriInterface $host)
50-
{
49+
function it_removes_ending_slashes(
50+
RequestInterface $request,
51+
UriInterface $host,
52+
UriInterface $host2,
53+
UriInterface $uri
54+
) {
5155
$host->getPath()->shouldBeCalled()->willReturn('/api/');
56+
$host2->getPath()->shouldBeCalled()->willReturn('/api');
57+
$host->withPath('/api')->shouldBeCalled()->willReturn($host2);
58+
59+
$request->getUri()->shouldBeCalled()->willReturn($uri);
60+
$request->withUri($uri)->shouldBeCalled()->willReturn($request);
61+
62+
$uri->withPath('/api/users')->shouldBeCalled()->willReturn($uri);
63+
$uri->getPath()->shouldBeCalled()->willReturn('/users');
5264

5365
$this->beConstructedWith($host);
54-
$this->shouldThrow(\LogicException::class)->duringInstantiation();
66+
$this->handleRequest($request, function () {}, function () {});
5567
}
5668

5769
public function it_throws_exception_on_empty_path(UriInterface $host)

src/Plugin/AddPathPlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(UriInterface $uri)
3333
}
3434

3535
if ('/' === substr($uri->getPath(), -1)) {
36-
throw new \LogicException('URI path cannot end with a slash.');
36+
$uri = $uri->withPath(rtrim($uri->getPath(), '/'));
3737
}
3838

3939
$this->uri = $uri;

0 commit comments

Comments
 (0)