Merge pull request #184 from tlvince/https-getfavicon

Retrieve favicons using protocol-relative URLs
This commit is contained in:
Athou
2013-05-25 22:15:34 -07:00

View File

@@ -43,13 +43,6 @@ module.directive('favicon', function() {
template : '<img ng-src="{{iconUrl()}}" class="favicon" onError="this.src=\'images/default_favicon.gif\'"></img>',
controller : ['$scope', function($scope) {
var firstLetterDomain = function(url) {
url = url.replace('http://', '');
url = url.replace('https://', '');
url = url.replace('www.', '');
return url.substring(0, 1);
};
$scope.iconUrl = function() {
var url = $scope.url;
@@ -60,10 +53,9 @@ module.directive('favicon', function() {
return defaultIcon;
}
var prefix = firstLetterDomain(url);
var index = Math.max(url.length, url.lastIndexOf('?'));
var iconUrl = 'http://' + prefix + '.getfavicon.appspot.com/';
var iconUrl = '//getfavicon.appspot.com/';
iconUrl += encodeURIComponent(url.substring(0, index));
iconUrl += '?defaulticon=none';
return iconUrl;
@@ -362,4 +354,4 @@ module.directive('spinner', function() {
});
}
};
});
});