Fix date math parser to not use hardcoded length (#17751)
* Fix date math parser to not use hardcoded length * Add test
This commit is contained in:
parent
b994ab3f56
commit
2ec9956885
|
@ -82,7 +82,7 @@ function parseDateMath(mathString, time, roundUp) {
|
|||
const numFrom = i;
|
||||
while (!isNaN(mathString.charAt(i))) {
|
||||
i++;
|
||||
if (i > 10) return;
|
||||
if (i >= len) return;
|
||||
}
|
||||
num = parseInt(mathString.substring(numFrom, i), 10);
|
||||
}
|
||||
|
|
|
@ -322,6 +322,10 @@ describe('dateMath', function() {
|
|||
.valueOf();
|
||||
expect(val).to.eql(anchored.startOf('s').valueOf());
|
||||
});
|
||||
|
||||
it('should parse long expressions', () => {
|
||||
expect(dateMath.parse('now-1d/d+8h+50m')).to.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
describe('used momentjs instance', function() {
|
||||
|
|
Loading…
Reference in a new issue