Browse Source

Replaced empty with strlen

Òscar Casajuana 10 years ago
parent
commit
a52a8d1330
2 changed files with 5 additions and 1 deletions
  1. 1 1
      src/Network/Request.php
  2. 4 0
      tests/TestCase/Network/RequestTest.php

+ 1 - 1
src/Network/Request.php

@@ -547,7 +547,7 @@ class Request implements ArrayAccess
         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] !== '/') {

+ 4 - 0
tests/TestCase/Network/RequestTest.php

@@ -574,6 +574,10 @@ class RequestTest extends TestCase
         $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);