From cf7051f9a70ad512d7435feae398d0310204f241 Mon Sep 17 00:00:00 2001 From: Cezar Augusto Date: Fri, 4 Nov 2016 21:34:23 -0200 Subject: [PATCH] Add fallback when a topSite doesn't have favicon Auditors: @bsclifton Fix #5332 Test Plan: * Inside getLetterFromUrl function (line 270), change site.get('title') to something else. I.e. site.get('titlenator') * On topSites grid, sites' tile should fallback to location's first letter * Change url.get('location') to something else. I.e. url.get('locationizer') * On topSites grid, sites' tile should fallback to '?' string --- js/about/newtab.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/js/about/newtab.js b/js/about/newtab.js index 872400a652d..3e3d30292cf 100644 --- a/js/about/newtab.js +++ b/js/about/newtab.js @@ -15,6 +15,7 @@ const SiteRemovalNotification = require('./newTabComponents/siteRemovalNotificat const FooterInfo = require('./newTabComponents/footerInfo') const aboutActions = require('./aboutActions') const siteUtil = require('../state/siteUtil') +const urlutils = require('../lib/urlutil') const siteTags = require('../constants/siteTags') const cx = require('../lib/classSet.js') const config = require('../constants/config') @@ -264,6 +265,12 @@ class NewTabPage extends React.Component { const gridLayoutSize = this.gridLayoutSize const gridLayout = this.gridLayout + const getLetterFromUrl = (url) => { + const hostname = urlutils.getHostname(url.get('location'), true) + const name = url.get('title') || hostname || '?' + return name.charAt(0).toUpperCase() + } + return
{ this.state.backgroundImage @@ -297,9 +304,7 @@ class NewTabPage extends React.Component { href={site.get('location')} favicon={ site.get('favicon') == null - ? site.get('title') - ? site.get('title').charAt(0).toUpperCase() - : '?' + ? getLetterFromUrl(site) : } style={{backgroundColor: site.get('themeColor')}}