Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't remove non-latin chars from search string; fixes #26 #30

Merged
merged 1 commit into from
Oct 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}

});