Skip to content

Commit 2321634

Browse files
committed
Fixed missing period when building accept header that caused a bug with multiple versions and internal requests.
Signed-off-by: Jason Lewis <[email protected]>
1 parent b0ba23e commit 2321634

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/Dispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ protected function createRequest($verb, $uri, $parameters)
318318
*/
319319
protected function buildAcceptHeader()
320320
{
321-
return 'application/vnd'.$this->router->getVendor().'.'.$this->version.'+json';
321+
return 'application/vnd.'.$this->router->getVendor().'.'.$this->version.'+json';
322322
}
323323

324324
/**

tests/DispatcherTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,22 @@ public function testInternalRequestUsingRouteNameAndControllerActionDoesNotDoubl
191191
$this->assertEquals('foo', $this->dispatcher->route('foo'));
192192
$this->assertEquals('foo', $this->dispatcher->action('InternalControllerActionRoutingStub@index'));
193193
}
194+
195+
196+
public function testInternalRequestWithMultipleVersionsCallsCorrectVersion()
197+
{
198+
$this->router->api(['version' => 'v1'], function()
199+
{
200+
$this->router->get('foo', function() { return 'foo'; });
201+
});
202+
203+
$this->router->api(['version' => 'v2'], function()
204+
{
205+
$this->router->get('foo', function() { return 'bar'; });
206+
});
207+
208+
$this->assertEquals('bar', $this->dispatcher->version('v2')->get('foo'));
209+
}
194210

195211

196212
}

0 commit comments

Comments
 (0)