Merge pull request #2777 from bagage/master

Trim extra whitespace that might be present in terms list
This commit is contained in:
Bryan Housel
2015-09-18 21:17:16 -04:00
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() {