Skip to content

Commit

Permalink
Updated base url parsing to account for app's folder structure changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Jan 12, 2014
1 parent 20b993f commit a1dac80
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 73 deletions.
14 changes: 4 additions & 10 deletions src/Network/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,11 @@ protected static function _base() {
if (!$baseUrl) {
$base = dirname(env('PHP_SELF'));

$indexPos = strpos($base, '/webroot/index.php');
$indexPos = strpos($base, '/' . $webroot . '/index.php');
if ($indexPos !== false) {
$base = substr($base, 0, $indexPos) . '/webroot';
$base = substr($base, 0, $indexPos) . '/' . $webroot;
}
if ($webroot === 'webroot' && $webroot === basename($base)) {
$base = dirname($base);
}
if ($dir === 'App' && $dir === basename($base)) {
if ($webroot === basename($base)) {
$base = dirname($base);
}

Expand All @@ -373,12 +370,9 @@ protected static function _base() {
$webrootDir = $base . '/';

$docRoot = env('DOCUMENT_ROOT');
$docRootContainsWebroot = strpos($docRoot, $dir . DS . $webroot);
$docRootContainsWebroot = strpos($docRoot, $webroot);

if (!empty($base) || !$docRootContainsWebroot) {
if (strpos($webrootDir, '/' . $dir . '/') === false) {
$webrootDir .= $dir . '/';
}
if (strpos($webrootDir, '/' . $webroot . '/') === false) {
$webrootDir .= $webroot . '/';
}
Expand Down
Loading

0 comments on commit a1dac80

Please sign in to comment.