Browse Source

Use config value instead of hardcoded "webroot" string.

ADmad 7 years ago
parent
commit
ba6059ce4b

+ 1 - 1
src/Http/ServerRequestFactory.php

@@ -130,7 +130,7 @@ abstract class ServerRequestFactory extends BaseFactory
         if (empty($path) || $path === '/' || $path === '//' || $path === '/index.php') {
             $path = '/';
         }
-        $endsWithIndex = '/webroot/index.php';
+        $endsWithIndex = '/' . (Configure::read('App.webroot') ?: 'webroot') . '/index.php';
         $endsWithLength = strlen($endsWithIndex);
         if (strlen($path) >= $endsWithLength &&
             substr($path, -$endsWithLength) === $endsWithIndex

+ 5 - 5
tests/TestCase/Http/ServerRequestFactoryTest.php

@@ -210,19 +210,19 @@ class ServerRequestFactoryTest extends TestCase
     {
         Configure::write('App', [
             'dir' => 'app',
-            'webroot' => 'webroot',
+            'webroot' => 'www',
             'base' => false,
             'baseUrl' => '/cake/index.php'
         ]);
         $server = [
             'DOCUMENT_ROOT' => '/Users/markstory/Sites',
-            'SCRIPT_FILENAME' => '/Users/markstory/Sites/cake/webroot/index.php',
-            'PHP_SELF' => '/cake/webroot/index.php/posts/index',
-            'REQUEST_URI' => '/cake/webroot/index.php',
+            'SCRIPT_FILENAME' => '/Users/markstory/Sites/cake/www/index.php',
+            'PHP_SELF' => '/cake/www/index.php/posts/index',
+            'REQUEST_URI' => '/cake/www/index.php',
         ];
         $res = ServerRequestFactory::fromGlobals($server);
 
-        $this->assertSame('/cake/webroot/', $res->getAttribute('webroot'));
+        $this->assertSame('/cake/www/', $res->getAttribute('webroot'));
         $this->assertSame('/cake/index.php', $res->getAttribute('base'));
         $this->assertSame('/', $res->getUri()->getPath());
     }