mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix: make PR template checklist header check case-insensitive (#66543)
This commit is contained in:
@@ -25,21 +25,21 @@ const TEMPLATE_BLOCK = [
|
||||
module.exports = async ({ github, context, isAllowListed }) => {
|
||||
if (isAllowListed === 'true') return;
|
||||
|
||||
const body = context.payload.pull_request.body || '';
|
||||
const body = (context.payload.pull_request.body || '').toLowerCase();
|
||||
|
||||
// The template must be present and the first 3 checkboxes must be
|
||||
// ticked ([x] or [X]). The last checkbox (tested locally) is
|
||||
// acceptable to leave unticked.
|
||||
const templatePresent = body.includes('Checklist:');
|
||||
// ticked. The last checkbox (tested locally) is acceptable to leave
|
||||
// unticked.
|
||||
const templatePresent = body.includes('checklist:');
|
||||
const requiredTicked = [
|
||||
'I have read and followed the contribution guidelines',
|
||||
'I have read and followed the how to open a pull request guide',
|
||||
'My pull request targets the'
|
||||
'i have read and followed the contribution guidelines',
|
||||
'i have read and followed the how to open a pull request guide',
|
||||
'my pull request targets the'
|
||||
];
|
||||
// Strip markdown links ([text](url) → text) before matching so contributors
|
||||
// who omit the link syntax (e.g. type plain text) still pass the check.
|
||||
const normalizedBody = body
|
||||
.replace(/\[\s*[xX]\s*\]/g, '[x]')
|
||||
.replace(/\[\s*x\s*\]/g, '[x]')
|
||||
.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1');
|
||||
const allRequiredTicked = requiredTicked.every(item =>
|
||||
normalizedBody.includes(`[x] ${item}`)
|
||||
|
||||
Reference in New Issue
Block a user