Commit 3c1b30e3 by Torkel Ödegaard

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

parent 5daefc8b
......@@ -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]
};
}
......
......@@ -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');
});
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment