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

Commit

Permalink
fix autosuggest error on file:/// URLs
Browse files Browse the repository at this point in the history
fix #8967
  • Loading branch information
diracdeltas committed May 19, 2017
1 parent da5b398 commit 6443918
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/common/lib/suggestion.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ const getSortByDomain = (userInputLower, userInputHost) => {
// any count or frequency calculation.
// Note that for parsed URLs that are not complete, the pathname contains
// what the user is entering as the host and the host is null.
const host1 = s1.parsedUrl.host || s1.parsedUrl.pathname
const host2 = s2.parsedUrl.host || s2.parsedUrl.pathname
const host1 = s1.parsedUrl.host || s1.parsedUrl.pathname || s1.location || ''
const host2 = s2.parsedUrl.host || s2.parsedUrl.pathname || s2.location || ''

let pos1 = host1.indexOf(userInputHost)
let pos2 = host2.indexOf(userInputHost)
Expand Down
3 changes: 3 additions & 0 deletions test/unit/app/common/lib/suggestionTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ describe('suggestion unit tests', function () {
it('simple domain gets matched higher', function () {
assert(this.sort('https://www.google.com', 'https://www.google.com/extra') < 0)
})
it('does not throw error for file:// URL', function () {
assert(this.sort('https://google.com', 'file://') < 0)
})
})
describe('getSortForSuggestions', function () {
describe('with url entered as path', function () {
Expand Down

0 comments on commit 6443918

Please sign in to comment.