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:
@@ -25,12 +25,12 @@ public function serves($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;
|
||||
}
|
||||
|
||||
if (file_exists($sitePath.'/storage/public/'.$uri)) {
|
||||
return $sitePath.'/public/'.$uri;
|
||||
if (file_exists($sitePath.'/storage/public'.$uri)) {
|
||||
return $sitePath.'/public'.$uri;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -29,9 +29,9 @@ public function isStaticFile($sitePath, $siteName, $uri)
|
||||
return false;
|
||||
} elseif (strpos($uri, '/local') === 0 || strpos($uri, '/statamic') === 0) {
|
||||
return false;
|
||||
} elseif (file_exists($staticFilePath = $sitePath.'/'.$uri)) {
|
||||
} elseif (file_exists($staticFilePath = $sitePath.$uri)) {
|
||||
return $staticFilePath;
|
||||
} elseif (file_exists($staticFilePath = $sitePath.'/public/'.$uri)) {
|
||||
} elseif (file_exists($staticFilePath = $sitePath.'/public'.$uri)) {
|
||||
return $staticFilePath;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,15 @@ public function serves($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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -95,7 +95,7 @@ public function serveStaticFile($staticFilePath, $sitePath, $siteName, $uri)
|
||||
{
|
||||
$mimes = require(__DIR__.'/../mimes.php');
|
||||
|
||||
header('Content-Type: '.$mimes[pathinfo($uri)['extension']]);
|
||||
header('Content-Type: '.$mimes[pathinfo($staticFilePath)['extension']]);
|
||||
|
||||
readfile($staticFilePath);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user