diff --git a/frontend/model/contracts/shared/time.js b/frontend/model/contracts/shared/time.js index d8674ff9b..ec8007549 100644 --- a/frontend/model/contracts/shared/time.js +++ b/frontend/model/contracts/shared/time.js @@ -224,7 +224,8 @@ export function timeSince (datems: number, dateNow: number = Date.now()): string if (interval >= DAYS_MILLIS * 2) { // Make sure to replace any ordinary space character by a non-breaking one. - return humanDate(datems).replace(/\x32/g, '\xa0') + // $FlowFixMe + return humanDate(datems).replaceAll(' ', '\xa0') } if (interval >= DAYS_MILLIS) { return L('1d') diff --git a/frontend/model/contracts/shared/time.test.js b/frontend/model/contracts/shared/time.test.js index 1349e8caa..d97f36d74 100644 --- a/frontend/model/contracts/shared/time.test.js +++ b/frontend/model/contracts/shared/time.test.js @@ -63,10 +63,10 @@ describe('timeSince', function () { )).equal('1d') }) - it('should return current day when +48h have passed', () => { + it('should return current day (with non-breaking space) when +48h have passed', () => { should(timeSince( currentDate - DAYS_MILLIS * 23, currentDate - )).equal('May 7') + )).equal('May\xa07') }) })