Skip to content

Commit a52a8d1

Browse files
committed
Replaced empty with strlen
1 parent 0de5b1d commit a52a8d1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Network/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ public function referer($local = false)
547547
if (!empty($ref) && !empty($base)) {
548548
if ($local && strpos($ref, $base) === 0) {
549549
$ref = substr($ref, strlen($base));
550-
if (empty($ref)) {
550+
if (!strlen($ref)) {
551551
$ref = '/';
552552
}
553553
if ($ref[0] !== '/') {

tests/TestCase/Network/RequestTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,10 @@ public function testReferer()
574574
$result = $request->referer(true);
575575
$this->assertSame('/some/path', $result);
576576

577+
$request->env('HTTP_REFERER', Configure::read('App.fullBaseUrl') . '/0');
578+
$result = $request->referer(true);
579+
$this->assertSame('/0', $result);
580+
577581
$request->env('HTTP_REFERER', Configure::read('App.fullBaseUrl') . '/');
578582
$result = $request->referer(true);
579583
$this->assertSame('/', $result);

0 commit comments

Comments
 (0)