Skip to content

Commit

Permalink
Merge pull request #6 from FreshRSS/protocol-relative
Browse files Browse the repository at this point in the history
Add compatibility with protocol relative URLs
  • Loading branch information
ArthurHoaro authored Apr 23, 2017
2 parents d74265d + cd5f98e commit 02163a1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Favicon/Favicon.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,15 @@ private function getFavicon($url, $checkDefault = true) {

// See if it's specified in a link tag in domain url.
if (!$favicon) {
$favicon = $this->getInPage($url);
$favicon = trim($this->getInPage($url));
}
// Case of protocol-relative URLs
if (substr($favicon, 0, 2) === '//') {
if (preg_match('%^(https?:)//%i', $url, $matches)) {
$favicon = $matches[1] . $favicon;
} else {
$favicon = 'https:' . $favicon;
}
}

// Make sure the favicon is an absolute URL.
Expand Down

0 comments on commit 02163a1

Please sign in to comment.