Skip to content

Commit

Permalink
Merge pull request #47 from pelias/empty_country_labels
Browse files Browse the repository at this point in the history
fix for rare cases where country labels are blank
  • Loading branch information
orangejulius authored Jun 9, 2021
2 parents be67d51 + 4b4f78f commit a1374a9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion labelGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function buildPrefixLabelParts(schema, record) {
return [];
}

if (isCountry(record.layer)) {
if (isCountry(record.layer) && !_.isEmpty(record.country)) {
return [];
}

Expand Down
14 changes: 14 additions & 0 deletions test/labelGenerator_examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,21 @@ module.exports.tests.name_only = function(test, common) {
t.equal(generator(doc),'Result name');
t.end();
});
};

// Geonames Philippines record has no admin info!
// https://github.com/pelias/api/issues/720
module.exports.tests.name_only_country = function (test, common) {
test('name-only results (no admin fields) - Geonames Philippines', function (t) {
var doc = {
'name': {
'default': 'Republic of the Philippines'
},
'layer': 'country'
};
t.equal(generator(doc), 'Republic of the Philippines');
t.end();
});
};

module.exports.all = function (tape, common) {
Expand Down

0 comments on commit a1374a9

Please sign in to comment.