Skip to content
Permalink
Browse files

Don't strip off `/` when it is the entire path.

Only remove `/` from URLs that are longer. Removing the `/` when it is
the only part of the path results in the created Uri object not having
its path reset.

Refs #12389
  • Loading branch information...
markstory committed Jul 25, 2018
1 parent 07685e9 commit a20381c7ba0787f9e7df24abf73b32558868742c
Showing with 17 additions and 1 deletion.
  1. +1 −1 src/Http/ServerRequest.php
  2. +16 −0 tests/TestCase/Http/ServerRequestTest.php
@@ -308,7 +308,7 @@ public function __construct($config = [])
*/
protected function _setConfig($config)
{
if (!empty($config['url']) && $config['url'][0] === '/') {
if (strlen($config['url']) > 1 && $config['url'][0] === '/') {
$config['url'] = substr($config['url'], 1);
}
@@ -158,6 +158,22 @@ public function testConstructionQueryData()
$this->assertEquals('/some/path', $request->getRequestTarget());
}
/**
* Test constructing with a string url.
*
* @deprecated
* @return void
*/
public function testConstructStringUrlIgnoreServer()
{
$_SERVER['REQUEST_URI'] = '/some/other/path';
$request = new ServerRequest('/articles/view/1');
$this->assertEquals('/articles/view/1', $request->getUri()->getPath());
$request = new ServerRequest('/');
$this->assertEquals('/', $request->getUri()->getPath());
}
/**
* Test that querystring args provided in the URL string are parsed.
*

0 comments on commit a20381c

Please sign in to comment.
You can’t perform that action at this time.