ash-jc-allen / favicon-fetcher

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

Fix HTTP driver bug if multiple link elements are on the same line #13

Closed ash-jc-allen closed 2 years ago

ash-jc-allen commented 2 years ago

This PR fixes a bug in the HTTP driver that was using the wrong <link> tag while parsing the HTML.

This bug happened if there were multiple <link> tags on the same line in the HTML. The preg_match function was grabbing the entire line and then we were returning the first link in the matches. So, this would return whichever link element was the first on the line.

Now, the code will explode the line and loop through the links to find the "icon" or "shortcut icon" element.