mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
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
c41b9dd73b
commit
f6f5e691f0
2 changed files with 5 additions and 1 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue