Skip to content

Commit

Permalink
Merge pull request laravel#69 from lukasgeiter/fix-trailing-slash
Browse files Browse the repository at this point in the history
Fix trailing slash
  • Loading branch information
taylorotwell committed Apr 30, 2015
2 parents 3da2d0a + 0665219 commit 1f6d8b5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,7 @@ public function getPathInfo()
{
$query = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';

return '/'.ltrim(str_replace('?'.$query, '', $_SERVER['REQUEST_URI']), '/');
return '/'.trim(str_replace('?'.$query, '', $_SERVER['REQUEST_URI']), '/');
}

/**
Expand Down
40 changes: 40 additions & 0 deletions tests/FullApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,46 @@ public function testBasicRequest()
}


public function testRequestWithoutSymfonyClass()
{
$app = new Application;

$app->get('/', function () {
return response('Hello World');
});

$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/';

$response = $app->dispatch();

$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals('Hello World', $response->getContent());

unset($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']);
}


public function testRequestWithoutSymfonyClassTrailingSlash()
{
$app = new Application;

$app->get('/foo', function () {
return response('Hello World');
});

$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/foo/';

$response = $app->dispatch();

$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals('Hello World', $response->getContent());

unset($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']);
}


public function testRequestWithParameters()
{
$app = new Application;
Expand Down

0 comments on commit 1f6d8b5

Please sign in to comment.