Skip to content

Commit

Permalink
try with /
Browse files Browse the repository at this point in the history
  • Loading branch information
florisbosch committed Dec 19, 2022
1 parent 3a38d32 commit bc482f5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/LogFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public function __construct(string $path)

// Let's remove the file name because we already know it.
$this->subFolder = str_replace($this->name, '', $path);
$this->subFolder = rtrim($this->subFolder, DIRECTORY_SEPARATOR);
$this->subFolder = rtrim($this->subFolder, '/');

// if (str_starts_with($path, DIRECTORY_SEPARATOR)) {
// if (str_starts_with($path, '/')) {
// $this->absolutePath = pathinfo($path)['dirname'];
// $this->path = pathinfo($path)['basename'];
// }
Expand Down
10 changes: 5 additions & 5 deletions src/LogFolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function files(): LogFileCollection
public function isRoot(): bool
{
return empty($this->path)
|| $this->path === rtrim(LogViewer::basePathForLogs(), DIRECTORY_SEPARATOR);
|| $this->path === rtrim(LogViewer::basePathForLogs(), '/');
}

public function cleanPath(): string
Expand All @@ -47,7 +47,7 @@ public function cleanPath(): string

$folder = $this->path;

$folder = str_replace(LogViewer::basePathForLogs(), 'root'.DIRECTORY_SEPARATOR, $folder);
$folder = str_replace(LogViewer::basePathForLogs(), 'root'.'/', $folder);

if ($unixHomePath = getenv('HOME')) {
$folder = str_replace($unixHomePath, '~', $folder);
Expand All @@ -64,7 +64,7 @@ public function pathParts(): array
return [];
}

return explode(DIRECTORY_SEPARATOR, $folder);
return explode('/', $folder);
}

public function pathFormatted(): string
Expand All @@ -75,7 +75,7 @@ public function pathFormatted(): string
return $folder;
}

return str_replace(DIRECTORY_SEPARATOR, ' '.DIRECTORY_SEPARATOR.' ', $folder);
return str_replace('/', ' '.'/'.' ', $folder);
}

public function earliestTimestamp(): int
Expand Down Expand Up @@ -109,7 +109,7 @@ public function download(): BinaryFileResponse

// zip it, and download it.
$zipFileName = $this->downloadFileName();
$zipPath = sys_get_temp_dir().DIRECTORY_SEPARATOR.$zipFileName;
$zipPath = sys_get_temp_dir().'/'.$zipFileName;

// just in case we have created it before.
@unlink($zipPath);
Expand Down
8 changes: 4 additions & 4 deletions src/LogViewerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected function getFilePaths(): array

foreach (config('log-viewer.include_files', []) as $pattern) {
$absolute = true;
if (! str_starts_with($pattern, DIRECTORY_SEPARATOR)) {
if (! str_starts_with($pattern, '/')) {
$pattern = $baseDir.$pattern;
$absolute = false;
}
Expand All @@ -49,7 +49,7 @@ protected function getFilePaths(): array

foreach (config('log-viewer.exclude_files', []) as $pattern) {
$absolute = true;
if (! str_starts_with($pattern, DIRECTORY_SEPARATOR)) {
if (! str_starts_with($pattern, '/')) {
$pattern = $baseDir.$pattern;
$absolute = false;
}
Expand Down Expand Up @@ -77,7 +77,7 @@ protected function getFilePathsMatchingPattern($pattern, $absolute = false): arr
foreach ($scannedFiles as $file) {
if (preg_match(pattern: Glob::toRegex(glob: $pattern), subject: $file)) {
$files[] = isset($dirname)
? $dirname.DIRECTORY_SEPARATOR.$file
? $dirname.'/'.$file
: $file;
}
}
Expand All @@ -90,7 +90,7 @@ public function basePathForLogs(): string
$rootFolder = Str::of(config('log-viewer.filesystem.root'));

return ($rootFolder != '')
? $rootFolder->finish(DIRECTORY_SEPARATOR)
? $rootFolder->finish('/')
: $rootFolder;
}

Expand Down
2 changes: 1 addition & 1 deletion src/LogViewerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function register()

$this->app['config']['filesystems.disks.log-viewer-local'] = [
'driver' => 'local',
'root' => storage_path('logs'),
'root' => str_replace('\\', '/', storage_path('logs')),
];

$this->app->bind('log-viewer', LogViewerService::class);
Expand Down

0 comments on commit bc482f5

Please sign in to comment.