diff --git a/index.js b/index.js index f226845..3e2b5dc 100644 --- a/index.js +++ b/index.js @@ -16,7 +16,7 @@ export default function parse(str = '', format = 'ms') { String(str) .replace(new RegExp(`(\\d)[${parse.unit.placeholder}${parse.unit.group}](\\d)`, 'g'), '$1$2') // clean up group separators / placeholders - .replace(parse.unit.decimal, '.') // normalize decimal separator + .replaceAll(parse.unit.decimal, '.') // normalize decimal separator .replace(durationRE, (_, n, units) => { // if no units, find next smallest units or fall back to format value // eg. 1h30 -> 1h30m diff --git a/test.js b/test.js index f846782..ed7c11e 100644 --- a/test.js +++ b/test.js @@ -177,5 +177,8 @@ t('locale separators', t => { t.equal(parse('30.000,65 seconds'), 30000650) t.equal(parse('30 000,65 seconds'), 30000650) t.equal(parse('30_000,65 seconds'), 30000650) + // every component's decimal separator must be normalized, not just the first + t.equal(parse('1,5 s 1,5 s'), 3000) + t.equal(parse('2,5h 3,5h'), 21600000) t.end() })