From 999de97a486e61a22dd72d48c36b61cae58eedce Mon Sep 17 00:00:00 2001 From: w3cj Date: Fri, 22 Nov 2024 15:44:19 -0700 Subject: [PATCH] update timestamp validation --- scripts/merging-show-validation.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/merging-show-validation.js b/scripts/merging-show-validation.js index f186fdb84..be52868a2 100644 --- a/scripts/merging-show-validation.js +++ b/scripts/merging-show-validation.js @@ -44,9 +44,12 @@ const extractUrls = (content) => { }; const validateTimestamps = (content) => { - // Updated regex to catch more patterns, including incorrect ones - const timestampRegex = /\b([0-5]?\d:[0-5]?\d(:[0-5]\d)?)\b|\b(\d{4})\b/g; - const potentialTimestamps = content.match(timestampRegex) || []; + // only check timestamps in show notes + content = content.split('### Show Notes')[1] || content; + // Regex to match timestamps with [ or = prefix, in formats HH:MM, HH:MM:SS, or HHMM + const timestampRegex = /(?:\[|=)(?:\d{2}:\d{2}(?::\d{2})?|\d{4})\b/g; + // Remove prefix from matched timestamps + const potentialTimestamps = (content.match(timestampRegex) || []).map((t) => t.slice(1)); const invalidTimestamps = potentialTimestamps.filter((timestamp) => { if (!timestamp.includes(':')) { // Catching cases like '0702' which should be invalid