Skip to content

Commit

Permalink
remove unsupported keys
Browse files Browse the repository at this point in the history
  • Loading branch information
VladislavMedved committed Jan 23, 2023
1 parent 7612087 commit ee73618
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ MapboxGeocoder.prototype = {
'countries',
'types',
'language',
'mode', // permanent so for actual for both v5 and v6
'mode',
'autocomplete',
'worldview'
];
Expand Down Expand Up @@ -686,13 +686,6 @@ MapboxGeocoder.prototype = {
this.options.version === 'v6' ? { longitude: coords[0], latitude: coords[1]} : { query: coords },
{limit: 1 }
);

// Remove config options not supported by the reverseGeocoder
['proximity', 'autocomplete', 'fuzzyMatch', 'bbox'].forEach(function(key) {
if (key in config) {
delete config[key]
}
});
} break;
case GEOCODE_REQUEST_TYPE.FORWARD: {
// Ensure that any reverse geocoding looking request is cleaned up
Expand All @@ -710,6 +703,18 @@ MapboxGeocoder.prototype = {
} break;
}

// Remove config options not supported by the reverseGeocoder and v5 keys if v6 mode chosen
const unsupportedKeys = [
...(requestType === GEOCODE_REQUEST_TYPE.REVERSE ? ['proximity', 'autocomplete', 'fuzzyMatch', 'bbox'] : []),
...(this.options.version === 'v6' ? v5Keys : [])
];

unsupportedKeys.forEach(function(key) {
if (key in config) {
delete config[key]
}
});

return config;
},

Expand Down

0 comments on commit ee73618

Please sign in to comment.