Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Some Bave Pages suggestion cleanup
Browse files Browse the repository at this point in the history
Before it was showing about:whatever twice for each item (title and location), also it was showing suggestions for about:newtab, about:blank and about:flash when those aren't useful.

Auditors: @aekeus
  • Loading branch information
bbondy committed Jul 10, 2016
1 parent 6bc2793 commit f2a9304
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions js/components/urlBarSuggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const ImmutableComponent = require('./immutableComponent')

const config = require('../constants/config.js')
const top500 = require('./../data/top500.js')
const {aboutUrls, isIntermediateAboutPage, isSourceAboutUrl, isUrl} = require('../lib/appUrlUtil')
const {aboutUrls, isNavigatableAboutPage, isSourceAboutUrl, isUrl} = require('../lib/appUrlUtil')
const Immutable = require('immutable')
const debounce = require('../lib/debounce.js')
const settings = require('../constants/settings')
Expand Down Expand Up @@ -135,7 +135,7 @@ class UrlBarSuggestions extends ImmutableComponent {
: null
}
{
suggestion.type !== suggestionTypes.SEARCH
suggestion.type !== suggestionTypes.SEARCH && suggestion.type !== suggestionTypes.ABOUT_PAGES
? <div className='suggestionLocation'>{suggestion.location}</div>
: null
}
Expand Down Expand Up @@ -295,7 +295,7 @@ class UrlBarSuggestions extends ImmutableComponent {

// about pages
suggestions = suggestions.concat(mapListToElements({
data: aboutUrls.keySeq().filter((x) => !isIntermediateAboutPage(x)),
data: aboutUrls.keySeq().filter((x) => isNavigatableAboutPage(x)),
maxResults: config.urlBarSuggestions.maxAboutPages,
type: suggestionTypes.ABOUT_PAGES,
clickHandler: navigateClickHandler((x) => x)}))
Expand Down
6 changes: 6 additions & 0 deletions js/lib/appUrlUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ module.exports.aboutUrls = new Immutable.Map({
module.exports.isIntermediateAboutPage = (location) =>
['about:safebrowsing', 'about:error', 'about:certerror'].includes(getBaseUrl(location))

module.exports.isNotImplementedAboutPage = (location) =>
['about:config', 'about:history'].includes(getBaseUrl(location))

module.exports.isNavigatableAboutPage = (location) =>
!module.exports.isIntermediateAboutPage(location) && !module.exports.isNotImplementedAboutPage(location) && !['about:newtab', 'about:blank', 'about:flash'].includes(getBaseUrl(location))

// Map of target URLs mapped to source about: URLs
const aboutUrlsReverse = new Immutable.Map(module.exports.aboutUrls.reduce((obj, v, k) => {
obj[v] = k
Expand Down

1 comment on commit f2a9304

@aekeus
Copy link
Member

@aekeus aekeus commented on f2a9304 Jul 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

Please sign in to comment.