spatie / laravel-medialibrary

Associate files with Eloquent models
https://spatie.be/docs/laravel-medialibrary
MIT License
5.78k stars 1.08k forks source link

Fix deletion of files without extension #3664

Closed cbaconnier closed 4 months ago

cbaconnier commented 4 months ago

Tests are failing in Laravel apps when using fake images generated by UploadedFile::fake()->image('image.jpg') as the file will be generated internally by tmpfile() and will be named (E.g.) phpGoZkJ9

Currently, it looks if the path contains the filename, including the dot: phpGoZkJ9.

I changed it to match the full filename after the forward slash / From my understanding, the $path will always have a forward slash (/) before the filename.

If there's a case where doesn't have a forward slash or uses double backslashes \\ (because Windows),I will happily update my PR to include corresponding scenarios and tests.

Thanks!

cbaconnier commented 4 months ago

I'm wondering why is there a foreach and a check without the extension though. Can a file have multiple extension without being itself a conversion or a responsive image?

freekmurze commented 4 months ago

Thanks!