1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-07 09:10:03 +01:00

improve static driver

This commit is contained in:
Taylor Otwell
2016-05-05 14:20:02 -05:00
parent 065072a72b
commit c29429ba60
4 changed files with 15 additions and 7 deletions

View File

@@ -25,12 +25,12 @@ public function serves($sitePath, $siteName, $uri)
*/ */
public function isStaticFile($sitePath, $siteName, $uri) public function isStaticFile($sitePath, $siteName, $uri)
{ {
if (file_exists($staticFilePath = $sitePath.'/public/'.$uri)) { if (file_exists($staticFilePath = $sitePath.'/public'.$uri)) {
return $staticFilePath; return $staticFilePath;
} }
if (file_exists($sitePath.'/storage/public/'.$uri)) { if (file_exists($sitePath.'/storage/public'.$uri)) {
return $sitePath.'/public/'.$uri; return $sitePath.'/public'.$uri;
} }
return false; return false;

View File

@@ -29,9 +29,9 @@ public function isStaticFile($sitePath, $siteName, $uri)
return false; return false;
} elseif (strpos($uri, '/local') === 0 || strpos($uri, '/statamic') === 0) { } elseif (strpos($uri, '/local') === 0 || strpos($uri, '/statamic') === 0) {
return false; return false;
} elseif (file_exists($staticFilePath = $sitePath.'/'.$uri)) { } elseif (file_exists($staticFilePath = $sitePath.$uri)) {
return $staticFilePath; return $staticFilePath;
} elseif (file_exists($staticFilePath = $sitePath.'/public/'.$uri)) { } elseif (file_exists($staticFilePath = $sitePath.'/public'.$uri)) {
return $staticFilePath; return $staticFilePath;
} }

View File

@@ -25,7 +25,15 @@ public function serves($sitePath, $siteName, $uri)
*/ */
public function isStaticFile($sitePath, $siteName, $uri) public function isStaticFile($sitePath, $siteName, $uri)
{ {
return $sitePath.$uri; if (file_exists($staticFilePath = $sitePath.$uri) && ! is_dir($staticFilePath)) {
return $staticFilePath;
} elseif (file_exists($staticFilePath = $sitePath.$uri.'/index.html')) {
return $staticFilePath;
} elseif (file_exists($staticFilePath = $sitePath.$uri)) {
return $staticFilePath;
}
return false;
} }
/** /**

View File

@@ -95,7 +95,7 @@ public function serveStaticFile($staticFilePath, $sitePath, $siteName, $uri)
{ {
$mimes = require(__DIR__.'/../mimes.php'); $mimes = require(__DIR__.'/../mimes.php');
header('Content-Type: '.$mimes[pathinfo($uri)['extension']]); header('Content-Type: '.$mimes[pathinfo($staticFilePath)['extension']]);
readfile($staticFilePath); readfile($staticFilePath);
} }