Graphite: parser fix for hard case where ip numbers are used as segments, Fixes #1224

This commit is contained in:
Torkel Ödegaard 2014-12-15 11:36:08 +01:00
parent 5daefc8b8e
commit 3c1b30e3c1
2 changed files with 16 additions and 1 deletions

View File

@ -67,9 +67,16 @@ define([
}
if (this.match('identifier') || this.match('number')) {
// hack to handle float numbers in metric segments
var parts = this.consumeToken().value.split('.');
if (parts.length === 2) {
this.tokens.splice(this.index, 0, { type: '.' });
this.tokens.splice(this.index + 1, 0, { type: 'number', value: parts[1] });
}
return {
type: 'segment',
value: this.consumeToken().value
value: parts[0]
};
}

View File

@ -165,6 +165,14 @@ define([
expect(rootNode.params[1].value).to.be('#B');
});
it('should parse metric expression with ip number segments', function() {
var parser = new Parser('5.10.123.5');
var rootNode = parser.getAst();
expect(rootNode.segments[0].value).to.be('5');
expect(rootNode.segments[1].value).to.be('10');
expect(rootNode.segments[2].value).to.be('123');
expect(rootNode.segments[3].value).to.be('5');
});
});