Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
matchAll is not polyfilled in runtime
Browse files Browse the repository at this point in the history
mshustov committed Feb 12, 2020
1 parent 96f1edb commit 9f491d4
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/core/server/logging/layouts/conversions/date.ts
Original file line number Diff line number Diff line change
@@ -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 = {

0 comments on commit 9f491d4

Please sign in to comment.