Skip to content

Commit

Permalink
Merge pull request #30 from embeepea/master
Browse files Browse the repository at this point in the history
don't remove non-latin chars from search string; fixes #26
  • Loading branch information
embeepea authored Oct 20, 2020
2 parents 2e687ff + 65757b8 commit 8396f34
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 8396f34

Please sign in to comment.