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

Handle different protocol prefixes in auto-suggest #5092

Merged
merged 1 commit into from
Oct 24, 2016
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
5 changes: 4 additions & 1 deletion app/renderer/lib/suggestion.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,8 @@ module.exports.simpleDomainNameValue = (site) => {
*
*/
module.exports.normalizeLocation = (location) => {
return location.replace(/www\./, '')
location = location.replace(/www\./, '')
Copy link
Member

Choose a reason for hiding this comment

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

Would it make more sense to use the window.URL object?
https://developer.mozilla.org/en-US/docs/Web/API/Window/URL

Also, another consideration would be if it makes sense to put the logic into our URL utils:
https://github.com/brave/browser-laptop/blob/master/js/lib/urlutil.js

Copy link
Member

Choose a reason for hiding this comment

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

++ for extra logic in url utils but I'll merge this as is for now

location = location.replace(/^http:\/\//, '')
location = location.replace(/^https:\/\//, '')
return location
}
4 changes: 2 additions & 2 deletions js/constants/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ module.exports = {
urlBarSuggestions: {
maxOpenedFrames: 2,
maxBookmarkSites: 2,
maxHistorySites: 2,
maxHistorySites: 3,
maxAboutPages: 2,
maxSearch: 3,
maxTopSites: 5
maxTopSites: 3
},
navigationBar: {
defaultSearchSuggestions: false,
Expand Down
4 changes: 2 additions & 2 deletions test/unit/lib/urlSuggestionTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const AGE_DECAY = 50

describe('suggestion', function () {
it('normalizes location', function () {
assert.ok(suggestion.normalizeLocation('https://www.site.com') === 'https://site.com', 'www. prefix removed')
assert.ok(suggestion.normalizeLocation('http://site.com') === 'http://site.com', 'location not modified')
assert.ok(suggestion.normalizeLocation('https://www.site.com') === 'site.com', 'www. prefix removed')
assert.ok(suggestion.normalizeLocation('http://site.com') === 'site.com', 'location not modified')
})

it('sorts sites correctly', function () {
Expand Down