Skip to content

Commit

Permalink
Replaced empty with strlen
Browse files Browse the repository at this point in the history
  • Loading branch information
elboletaire committed May 9, 2016
1 parent 0de5b1d commit a52a8d1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Network/Request.php
Expand Up @@ -547,7 +547,7 @@ public function referer($local = false)
if (!empty($ref) && !empty($base)) {
if ($local && strpos($ref, $base) === 0) {
$ref = substr($ref, strlen($base));
if (empty($ref)) {
if (!strlen($ref)) {
$ref = '/';
}
if ($ref[0] !== '/') {
Expand Down
4 changes: 4 additions & 0 deletions tests/TestCase/Network/RequestTest.php
Expand Up @@ -574,6 +574,10 @@ public function testReferer()
$result = $request->referer(true);
$this->assertSame('/some/path', $result);

$request->env('HTTP_REFERER', Configure::read('App.fullBaseUrl') . '/0');
$result = $request->referer(true);
$this->assertSame('/0', $result);

$request->env('HTTP_REFERER', Configure::read('App.fullBaseUrl') . '/');
$result = $request->referer(true);
$this->assertSame('/', $result);
Expand Down

0 comments on commit a52a8d1

Please sign in to comment.