Skip to content

Commit

Permalink
don't remove non-latin chars from search string
Browse files Browse the repository at this point in the history
  • Loading branch information
embeepea committed Oct 20, 2020
1 parent 2e687ff commit 65757b8
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions mbgl-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,12 @@ document.addEventListener("DOMContentLoaded", function(){


function DoSearch() {
const query = searchQueryText.value;
const sanitizedQuery = sanitizeString(query);
const encodedSanitizedQuery = encodeURI(sanitizedQuery);
const query = searchQueryText.value.trim();
const encodedQuery = encodeURIComponent(query);
const bounds = map.getBounds();
const viewbox = [bounds.getWest(),bounds.getSouth(),bounds.getEast(),bounds.getNorth()].join(',');
const url = 'https://nomina.re.city/search?format=json&extratags=1'
+ '&q=' + encodedSanitizedQuery
+ '&q=' + encodedQuery
+ '&viewbox=' + viewbox
+ '&accept-language=en-US,en';
searchResults.classList.remove('kartta-hidden');
Expand Down Expand Up @@ -262,10 +261,4 @@ document.addEventListener("DOMContentLoaded", function(){
});

}

function sanitizeString(str){
str = str.replace(/[^a-z0-9áéíóúñü \.,_-]/gim,"");
return str.trim();
}

});

0 comments on commit 65757b8

Please sign in to comment.