From b24c3e9a6c20b5eee7cf86feffb4f74e1fc7949c Mon Sep 17 00:00:00 2001 From: adarshswaminath Date: Fri, 9 Oct 2026 22:54:16 +0530 Subject: [PATCH] fix(common): allow DateInput to accept a dot separator --- packages/common/src/dates/IntlDateFormat.ts | 2 +- packages/common/src/dates/__tests__/IntlDateFormat.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/common/src/dates/IntlDateFormat.ts b/packages/common/src/dates/IntlDateFormat.ts index 65b05c33b2..389dc38740 100644 --- a/packages/common/src/dates/IntlDateFormat.ts +++ b/packages/common/src/dates/IntlDateFormat.ts @@ -47,7 +47,7 @@ export class IntlDateFormat { this.separator = props.separator; this.invalidDateFormatRegex = new RegExp(`[^0-9${this.separator}]`); - this.duplicateSeparatorRegex = new RegExp(`${this.separator}{2,}`, 'g'); + this.duplicateSeparatorRegex = new RegExp(`${this.separator.replace(/\./g, '\\.')}{2,}`, 'g'); this.dateTimeFormat = new Intl.DateTimeFormat(props.locale); this.dateTimeFormatParts = this.dateTimeFormat.formatToParts(new Date()); diff --git a/packages/common/src/dates/__tests__/IntlDateFormat.test.ts b/packages/common/src/dates/__tests__/IntlDateFormat.test.ts index 52c2eef38d..e5f65e507b 100644 --- a/packages/common/src/dates/__tests__/IntlDateFormat.test.ts +++ b/packages/common/src/dates/__tests__/IntlDateFormat.test.ts @@ -33,7 +33,7 @@ describe('IntlDateFormat', () => { expect(intlDateFormat.locale).toBe('fr-CA'); expect(intlDateFormat.separator).toBe('.'); expect(intlDateFormat.invalidDateFormatRegex).toEqual(new RegExp(`[^0-9.]`)); - expect(intlDateFormat.duplicateSeparatorRegex).toEqual(new RegExp(`.{2,}`, 'g')); + expect(intlDateFormat.duplicateSeparatorRegex).toEqual(new RegExp('\\.{2,}', 'g')); expect(intlDateFormat.dateTimeFormat).toBeInstanceOf(Intl.DateTimeFormat); expect(intlDateFormat.dateTimeFormat.resolvedOptions().locale).toBe('fr-CA'); expect(intlDateFormat.dateTimeFormatParts[0].type).toBe('year');