Skip to content

Commit

Permalink
update timestamp validation
Browse files Browse the repository at this point in the history
  • Loading branch information
w3cj committed Nov 22, 2024
1 parent 3b316ba commit 999de97
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions scripts/merging-show-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 999de97

Please sign in to comment.