From 9802b0dcf498e51473e1187f85e1de1cb6931e1e Mon Sep 17 00:00:00 2001 From: wivaku Date: Wed, 5 Feb 2025 10:20:39 +0100 Subject: [PATCH] check if filename has extension Fix for bug https://github.com/pxlrbt/filament-excel/issues/95 Checks if filename ends with dot and 3-4 characters. (note: using 3-4 as this matches the intended use case: csv, xlsx) --- src/Exports/Concerns/WithFilename.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Exports/Concerns/WithFilename.php b/src/Exports/Concerns/WithFilename.php index 3bea9b2..243ac56 100644 --- a/src/Exports/Concerns/WithFilename.php +++ b/src/Exports/Concerns/WithFilename.php @@ -27,7 +27,7 @@ abstract protected function getDefaultExtension(): string; protected function ensureFilenameHasExtension(string $filename): string { - return Str::contains($filename, '.') + return Str::of($filename)->test('/\.\w{3,4}$/') ? $filename : $filename.'.'.$this->getDefaultExtension(); }