Skip to content

Commit ee73618

Browse files
remove unsupported keys
1 parent 7612087 commit ee73618

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

lib/index.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ MapboxGeocoder.prototype = {
633633
'countries',
634634
'types',
635635
'language',
636-
'mode', // permanent so for actual for both v5 and v6
636+
'mode',
637637
'autocomplete',
638638
'worldview'
639639
];
@@ -686,13 +686,6 @@ MapboxGeocoder.prototype = {
686686
this.options.version === 'v6' ? { longitude: coords[0], latitude: coords[1]} : { query: coords },
687687
{limit: 1 }
688688
);
689-
690-
// Remove config options not supported by the reverseGeocoder
691-
['proximity', 'autocomplete', 'fuzzyMatch', 'bbox'].forEach(function(key) {
692-
if (key in config) {
693-
delete config[key]
694-
}
695-
});
696689
} break;
697690
case GEOCODE_REQUEST_TYPE.FORWARD: {
698691
// Ensure that any reverse geocoding looking request is cleaned up
@@ -710,6 +703,18 @@ MapboxGeocoder.prototype = {
710703
} break;
711704
}
712705

706+
// Remove config options not supported by the reverseGeocoder and v5 keys if v6 mode chosen
707+
const unsupportedKeys = [
708+
...(requestType === GEOCODE_REQUEST_TYPE.REVERSE ? ['proximity', 'autocomplete', 'fuzzyMatch', 'bbox'] : []),
709+
...(this.options.version === 'v6' ? v5Keys : [])
710+
];
711+
712+
unsupportedKeys.forEach(function(key) {
713+
if (key in config) {
714+
delete config[key]
715+
}
716+
});
717+
713718
return config;
714719
},
715720

0 commit comments

Comments
 (0)