mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
fix bug in "lang=badvalue" handling for wikidata api
see https://github.com/openstreetmap/iD/pull/9638#issuecomment-1623497481
This commit is contained in:
@@ -17,7 +17,7 @@ export default {
|
||||
|
||||
|
||||
// Search for Wikidata items matching the query
|
||||
itemsForSearchQuery: function _itemsForSearchQuery(query, callback, language) {
|
||||
itemsForSearchQuery: function(query, callback, language) {
|
||||
if (!query) {
|
||||
if (callback) callback('No query', {});
|
||||
return;
|
||||
@@ -40,13 +40,14 @@ export default {
|
||||
});
|
||||
|
||||
d3_json(url)
|
||||
.then(function(result) {
|
||||
.then(result => {
|
||||
if (result && result.error) {
|
||||
if (result.error.code === 'badvalue' &&
|
||||
result.error.info.includes(lang) &&
|
||||
!language && lang.includes('-')) {
|
||||
// retry without "country suffix" region subtag
|
||||
_itemsForSearchQuery(query, callback, lang.split('-')[0]);
|
||||
this.itemsForSearchQuery(query, callback, lang.split('-')[0]);
|
||||
return;
|
||||
} else {
|
||||
throw new Error(result.error);
|
||||
}
|
||||
|
||||
@@ -146,7 +146,10 @@ export function uiFieldWikidata(field, context) {
|
||||
}
|
||||
|
||||
wikidata.itemsForSearchQuery(q, function(err, data) {
|
||||
if (err) return;
|
||||
if (err) {
|
||||
if (err !== 'No query') console.error(err);
|
||||
return;
|
||||
}
|
||||
|
||||
var result = data.map(function (item) {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user