Skip to content

Commit

Permalink
Merge pull request #1932 from brave/ntp-topsites-valid-sites
Browse files Browse the repository at this point in the history
do not count urls in NTP top sites not coming from http or https
  • Loading branch information
bsclifton authored and cezaraugusto committed Mar 13, 2019
1 parent d5c9d26 commit f1b52ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion components/brave_new_tab_ui/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { bindActionCreators } from 'redux'
import * as newTabActions from './actions/new_tab_actions'
import { debounce } from '../common/debounce'
import store from './store'
import { isHttpOrHttps } from './helpers/newTabUtils'

let actions: any

Expand Down Expand Up @@ -57,7 +58,8 @@ export const getGridSites = (state: NewTab.State, checkBookmarkInfo?: boolean) =
let gridSites = state.topSites.slice()
.filter((site) =>
!state.ignoredTopSites.find((ignoredSite) => ignoredSite.url === site.url) &&
!state.pinnedTopSites.find((pinnedSite) => pinnedSite.url === site.url)
!state.pinnedTopSites.find((pinnedSite) => pinnedSite.url === site.url) &&
!isHttpOrHttps(site.url)
)

// Then add in pinned sites at the specified index, these need to be added in the same
Expand Down
10 changes: 10 additions & 0 deletions components/brave_new_tab_ui/helpers/newTabUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

export const isHttpOrHttps = (url?: string) => {
if (!url) {
return false
}
return /^https?:/i.test(url)
}

0 comments on commit f1b52ce

Please sign in to comment.