substring filter fixes for clients

This commit is contained in:
Mark Cavage 2011-09-19 12:24:16 -07:00
parent ed1ae29054
commit 9b67dc608a
2 changed files with 12 additions and 6 deletions

View File

@ -154,9 +154,9 @@ function _parseString(str) {
} else {
filters.push(new SubstringFilter({
attribute: stack[i].attribute,
initial: vals.shift(),
'final': vals.pop(),
any: vals
initial: vals.shift() || null,
'final': vals.pop() || null,
any: vals || null
}));
}
}

View File

@ -16,9 +16,9 @@ function SubstringFilter(options) {
if (!options.attribute || typeof(options.attribute) !== 'string')
throw new TypeError('options.attribute (string) required');
this.attribute = options.attribute;
this.initial = options.initial;
this.initial = options.initial || null;
this.any = options.any ? options.any.slice(0) : [];
this['final'] = options['final'];
this['final'] = options['final'] || null;
} else {
options = {};
}
@ -45,13 +45,19 @@ module.exports = SubstringFilter;
SubstringFilter.prototype.toString = function() {
var str = '(' + this.attribute + '=';
if (this.initial)
str += this.initial + '*';
str += this.initial;
str += '*';
this.any.forEach(function(s) {
str += s + '*';
});
if (this['final'])
str += this['final'];
str += ')';
return str;