ash-jc-allen / favicon-fetcher

A Laravel package for fetching favicons from websites.
MIT License
167 stars 13 forks source link

Wrong file extension when storing the favicon. #16

Closed misbahansori closed 2 years ago

misbahansori commented 2 years ago

Hi thanks for this nice package, but I think there is a problem. When storing the favicon in the storage I got this result :

$favicon = Favicon::fetch('https://headlessui.com')->store('favicons', 'public');
// 6f886546-edc2-4041-9a5c-8803f236ac25.com

$favicon = Favicon::fetch('https://vuejs.org')->store('favicons', 'public');
// favicons/bf4d32f3-fd86-4696-9a01-482d810da7f9.org

$favicon = Favicon::fetch('https://remote.io')->store('favicons', 'public');
// favicons/d0e9c6d4-2cd5-4abd-ac53-2fcad9ff817a.io

The file extension follows the URL domain. that's should not be the case, it should be .png or other image formats.

ash-jc-allen commented 2 years ago

Hey! I'm sorry that you're having issues with the package.

I can't seem to reproduce this locally. The https://headlessui.com appears to be stored as an .ico file for me; https://vuejs.org is being stored as an .svg; and https://remote.io as a .png.

I'll see if I can do a bit more digging and spot anything. Which driver are you using that's causing the issue? Does you get the same problem when using any other driver? And have you also tried clearing your cache to see if that improves anything? 🙂

misbahansori commented 2 years ago

I've checked that using the 'http' driver work like in your comment. But, using "google-shared-stuff", "favicon-kit" and "unavatar" gives the wrong extension. I suspect that the issue is in the image below :

Screen Shot 2022-07-23 at 19 03 47

It's trying to get the extension from the URL

ash-jc-allen commented 2 years ago

Ahh yeah, thanks for pointing that out! I'll try and put a fix together for that now 🙂

ash-jc-allen commented 2 years ago

I've tagged and released v1.1.2 (https://github.com/ash-jc-allen/favicon-fetcher/releases/tag/v1.1.2) that should hopefully fix this issue. Please let me know if the issue stills exists though 😄

misbahansori commented 2 years ago

The issue has been fixed. Thank you very much.