Skip to content

Commit 0323db2

Browse files
committed
Update index.js
1 parent fc4b00a commit 0323db2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,9 @@ MapboxGeocoder.prototype = {
648648
case GEOCODE_REQUEST_TYPE.FORWARD: {
649649
// Ensure that any reverse geocoding looking request is cleaned up
650650
// to be processed as only a forward geocoding request by the server.
651-
const reverseGeocodeCoordRgx = /^[ ]*(-?\d{1,3}(\.\d{0,256})?)[, ]+(-?\d{1,3}(\.\d{0,256})?)?[ ]*$/;
652-
if (reverseGeocodeCoordRgx.test(search)) {
651+
const trimmedSearch = search.trim();
652+
const reverseGeocodeCoordRgx = /^(-?\d{1,3}(\.\d{0,256})?)[, ]+(-?\d{1,3}(\.\d{0,256})?)?$/;
653+
if (reverseGeocodeCoordRgx.test(trimmedSearch)) {
653654
search = search.replace(/,/g, ' ');
654655
}
655656
config = extend(config, { query: search });

0 commit comments

Comments
 (0)