mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-18 14:45:12 +02:00
preset.js: trim terms when retrieving translations to avoid white spaces
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user