diff --git a/modules/services/taginfo.js b/modules/services/taginfo.js index 72d7f0de4..5bb74b47e 100644 --- a/modules/services/taginfo.js +++ b/modules/services/taginfo.js @@ -191,7 +191,13 @@ export function init() { page: 1 }, parameters)), debounce, function(err, d) { if (err) return callback(err); - var f = filterValues(parameters.key === 'cycle_network' || parameters.key === 'network'); + // In most cases we prefer taginfo value results with lowercase letters. + // A few OSM keys expect values to contain uppercase values (see #3377). + // This is not an exhaustive list (e.g. `name` also has uppercase values) + // but these are the fields where taginfo value lookup is most useful. + var re = /network|taxon|genus|species/; + var allowUpperCase = (parameters.key.match(re) !== null); + var f = filterValues(allowUpperCase); callback(null, d.data.filter(f).map(valKeyDescription)); }); }; diff --git a/test/spec/services/taginfo.js b/test/spec/services/taginfo.js index 82d3f0765..3f791e9c3 100644 --- a/test/spec/services/taginfo.js +++ b/test/spec/services/taginfo.js @@ -195,6 +195,42 @@ describe('iD.serviceTaginfo', function() { {'value':'US:MD','title':'State highways in the U.S. state of Maryland.'} ]); }); + + it('includes biological genus values with capital letters', function() { + var callback = sinon.spy(); + taginfo.values({key: 'genus', query: 'qu'}, callback); + + server.respondWith('GET', new RegExp('https://taginfo.openstreetmap.org/api/4/key/values'), + [200, { 'Content-Type': 'application/json' }, + '{"data":[{"value":"Quercus","description":"Oak", "fraction":0.5}]}']); + server.respond(); + + expect(callback).to.have.been.calledWith(null, [{'value':'Quercus','title':'Oak'}]); + }); + + it('includes biological taxon values with capital letters', function() { + var callback = sinon.spy(); + taginfo.values({key: 'taxon', query: 'qu'}, callback); + + server.respondWith('GET', new RegExp('https://taginfo.openstreetmap.org/api/4/key/values'), + [200, { 'Content-Type': 'application/json' }, + '{"data":[{"value":"Quercus robur","description":"Oak", "fraction":0.5}]}']); + server.respond(); + + expect(callback).to.have.been.calledWith(null, [{'value':'Quercus robur','title':'Oak'}]); + }); + + it('includes biological species values with capital letters', function() { + var callback = sinon.spy(); + taginfo.values({key: 'species', query: 'qu'}, callback); + + server.respondWith('GET', new RegExp('https://taginfo.openstreetmap.org/api/4/key/values'), + [200, { 'Content-Type': 'application/json' }, + '{"data":[{"value":"Quercus robur","description":"Oak", "fraction":0.5}]}']); + server.respond(); + + expect(callback).to.have.been.calledWith(null, [{'value':'Quercus robur','title':'Oak'}]); + }); }); describe('#roles', function() {