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

Add short domains to url suggestions when long url is present #7534

Merged
merged 1 commit into from
Mar 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/renderer/lib/suggestion.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ module.exports.createVirtualHistoryItems = (historySites) => {
})
// find groups with more than 2 of the same host
var multiGroupKeys = _.filter(_.keys(grouped), (k) => {
return grouped[k].length > 2
return grouped[k].length > 0
})
// potentially create virtual history items
var virtualHistorySites = _.map(multiGroupKeys, (location) => {
Expand All @@ -196,5 +196,7 @@ module.exports.createVirtualHistoryItems = (historySites) => {
virtualHistorySites = _.filter(virtualHistorySites, (site) => {
return !!site
})
return virtualHistorySites
return Immutable.fromJS(_.object(virtualHistorySites.map((site) => {
return [site.location, site]
})))
}
15 changes: 7 additions & 8 deletions test/unit/lib/urlSuggestionTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const suggestion = require('../../../app/renderer/lib/suggestion')
const assert = require('assert')
const Immutable = require('immutable')
const _ = require('underscore')

require('../braveUnit')

Expand Down Expand Up @@ -68,13 +69,11 @@ const site3 = Immutable.Map({
describe('suggestion', function () {
it('shows virtual history item', function () {
var history = Immutable.List([site1, site2, site3])
var virtual = suggestion.createVirtualHistoryItems(history)
assert.ok(virtual.length > 0, 'virtual location created')
assert.ok(virtual[0].get('location') === 'http://www.foo.com')
assert.ok(virtual[0].get('title') === 'www.foo.com')
assert.ok(virtual[0].get('lastAccessedTime') > 0)
history = Immutable.List([site1, site2])
virtual = suggestion.createVirtualHistoryItems(history)
assert.ok(virtual.length === 0, 'virtual location not created')
var virtual = suggestion.createVirtualHistoryItems(history).toJS()
var keys = _.keys(virtual)
assert.ok(keys.length > 0, 'virtual location created')
assert.ok(virtual[keys[0]].location === 'http://www.foo.com')
assert.ok(virtual[keys[0]].title === 'www.foo.com')
assert.ok(virtual[keys[0]].lastAccessedTime > 0)
})
})