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

Commit

Permalink
Merge pull request #7534 from brave/show-short-domain-url-bar
Browse files Browse the repository at this point in the history
Add short domains to url suggestions when long url is present
  • Loading branch information
bbondy authored Mar 11, 2017
2 parents a0a429a + 73c0cc2 commit c738e7f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
6 changes: 4 additions & 2 deletions app/renderer/lib/suggestion.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,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 @@ -199,5 +199,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)
})
})

0 comments on commit c738e7f

Please sign in to comment.