From e640c81aa2fa3ebd38f0f5d6107679bdcf49a188 Mon Sep 17 00:00:00 2001 From: Tom Vincent Date: Sun, 26 May 2013 12:11:23 +0800 Subject: [PATCH] Retrieve favicons using protocol-relative URLs If you are serving commafeed over https, many mixed content warnings are thrown on the getfavicon requests, e.g.: The page at https://commafeed.com/ displayed insecure content from http://d.getfavicon.appspot.com/http%3A%2F%2Fwww.dailywritingtips.com?defaulticon=none. However, simply removing 'http:' from getfavicon's iconUrl to give a [protocol-relative url][1] causes some browsers (Chromium) to throw an 'Identity not verified' error because you are using getfavicon's 'multiple domains' feature. Presumably, appspot.com's SSL certificate does not match sub-sub domain's and/or Chromium has stricter SSL policies (the same thing works in Safari). We can workaround that by dropping the multiple domain support and hence removal of the 'firstLetterDomain' function. Hopefully there's not too much of a performance degradation? [1]: http://www.paulirish.com/2010/the-protocol-relative-url/ --- src/main/webapp/js/directives.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/main/webapp/js/directives.js b/src/main/webapp/js/directives.js index 09646e90..5ceb53d7 100644 --- a/src/main/webapp/js/directives.js +++ b/src/main/webapp/js/directives.js @@ -43,13 +43,6 @@ module.directive('favicon', function() { template : '', 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() { }); } }; -}); \ No newline at end of file +});