preset.js: trim terms when retrieving translations to avoid white spaces

This commit is contained in:
Gautier Pelloux-Prayer
2015-09-14 19:13:30 +02:00
parent 0083977a27
commit 79b4c37733
2 changed files with 6 additions and 5 deletions
+5 -4
View File
@@ -31,6 +31,11 @@ iD.presets.Collection = function(collection) {
return a.suggestion === true;
});
function leading(a) {
var index = a.indexOf(value);
return index === 0 || a[index - 1] === ' ';
}
// matches value to preset.name
var leading_name = _.filter(searchable, function(a) {
return leading(a.name().toLowerCase());
@@ -50,10 +55,6 @@ iD.presets.Collection = function(collection) {
return _.any(_.without(_.values(a.tags || {}), '*'), leading);
});
function leading(a) {
var index = a.indexOf(value);
return index === 0 || a[index - 1] === ' ';
}
// finds close matches to value in preset.name
var levenstein_name = searchable.map(function(a) {
+1 -1
View File
@@ -46,7 +46,7 @@ iD.presets.Preset = function(id, preset, fields) {
};
preset.terms = function() {
return preset.t('terms', {'default': ''}).toLowerCase().split(/\s*,+\s*/);
return preset.t('terms', {'default': ''}).toLowerCase().trim().split(/\s*,+\s*/);
};
preset.isFallback = function() {