diff --git a/index.js b/index.js index cfc5fa2..90380a5 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ import en from './locale/en.js' -const durationRE = /((?:\d{1,16}(?:\.\d{1,16})?|\.\d{1,16})(?:[eE][-+]?\d{1,4})?)\s*([\p{L}]{0,14})/gu +const durationRE = /((?:\d+(?:\.\d+)?|\.\d+)(?:[eE][-+]?\d+)?)\s*([\p{L}]{0,14})/gu parse.unit = en diff --git a/test.js b/test.js index d806c9a..f292ee3 100644 --- a/test.js +++ b/test.js @@ -210,3 +210,10 @@ t('custom locale without group/placeholder', t => { parse.unit = en t.end() }) + +t('numbers with long digit runs are not split into separate matches', t => { + t.equal(parse('0.30000000000000004s'), 0.30000000000000004 * 1000) + t.equal(parse('0.12345678901234567s'), 0.12345678901234567 * 1000) + t.equal(parse('12345678901234567ms'), 12345678901234567) + t.end() +})