Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
fix(formatHit): fixed npe, not all hits have a country (#292)
Browse files Browse the repository at this point in the history
Fix #291
  • Loading branch information
redox authored Jul 20, 2016
1 parent eebb830 commit ff54319
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/formatHit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import findCountryCode from './findCountryCode.js';
import findType from './findType.js';

function getBestHighlightedForm(highlightedValues) {
if (highlightedValues.length === 0) {
return undefined;
}
const defaultValue = highlightedValues[0].value;
// collect all other matches
const bestAttributes = [];
Expand Down Expand Up @@ -46,7 +49,7 @@ export default function formatHit({
name: getBestHighlightedForm(hit._highlightResult.locale_names),
city: city ? getBestHighlightedForm(hit._highlightResult.city) : undefined,
administrative: administrative ? getBestHighlightedForm(hit._highlightResult.administrative) : undefined,
country: hit._highlightResult.country.value
country: country ? hit._highlightResult.country.value : undefined
};

const suggestion = {
Expand Down

0 comments on commit ff54319

Please sign in to comment.