Skip to content

Commit b2ada90

Browse files
committed
feat: history match file that prefix is same
1 parent dee0e9a commit b2ada90

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

Log.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,8 @@ public static function extractFileName($alias, $stamp = null)
193193
public static function extractFileStamp($alias, $fileName)
194194
{
195195
$originName = FileHelper::normalizePath(Yii::getAlias($alias, false));
196-
$origInfo = pathinfo($originName);
197-
$fileInfo = pathinfo($fileName);
198-
if (
199-
$origInfo['dirname'] === $fileInfo['dirname']
200-
&& strpos($fileInfo['filename'], $origInfo['filename']) === 0
201-
) {
202-
return $fileInfo['extension'];
196+
if (strpos($fileName, $originName) === 0) {
197+
return substr($fileName, strlen($originName) + 1);
203198
} else {
204199
return null;
205200
}

controllers/DefaultController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ public function actionView($slug, $stamp = null)
3939
{
4040
$log = $this->find($slug, $stamp);
4141
if ($log->isExist) {
42-
return Yii::$app->response->sendFile($log->fileName, $log->downloadName, ['inline' => true]);
42+
return Yii::$app->response->sendFile($log->fileName, basename($log->fileName), [
43+
'mimeType' => 'text/plain',
44+
'inline' => true
45+
]);
4346
} else {
4447
throw new NotFoundHttpException('Log not found.');
4548
}

0 commit comments

Comments
 (0)