From 9f491d4f535aa25e327961ffca4755039cf18040 Mon Sep 17 00:00:00 2001 From: Mikhail Shustov Date: Wed, 12 Feb 2020 14:27:04 +0100 Subject: [PATCH] matchAll is not polyfilled in runtime --- .../logging/layouts/conversions/date.ts | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/core/server/logging/layouts/conversions/date.ts b/src/core/server/logging/layouts/conversions/date.ts index d3ed54fb98240..2cce5d9c97c84 100644 --- a/src/core/server/logging/layouts/conversions/date.ts +++ b/src/core/server/logging/layouts/conversions/date.ts @@ -67,16 +67,22 @@ function validateTimezone(timezone: string) { } function validate(rawString: string) { - for (const matched of rawString.matchAll(dateRegExp)) { - const { format, timezone } = matched.groups!; + // clone regexp for exec since it's stateful with g flag + const regExp = new RegExp(dateRegExp, 'g'); + let matched: RegExpExecArray | null; + do { + matched = regExp.exec(rawString); + if (matched) { + const { format, timezone } = matched.groups!; - if (format) { - validateDateFormat(format); + if (format) { + validateDateFormat(format); + } + if (timezone) { + validateTimezone(timezone); + } } - if (timezone) { - validateTimezone(timezone); - } - } + } while (matched); } export const DateConversion: Conversion = {