fix(flatpak): read the changelog date without building a regex from input

This commit is contained in:
Erwan Leboucher committed 2026-09-24 15:44:15 +02:00
1 parent 6cb735778f
commit bb792e0558
1 file changed
+6 -3
+6 -3
View File
@@ -15,9 +15,12 @@ if (!version || !/^\d+\.\d+\.\d+/.test(version)) {
}
const changelog = readFileSync('CHANGELOG.md', 'utf8');
const date = changelog.match(
new RegExp(`\\n## ${version.replaceAll('.', '\\.')} \\((\\d{4}-\\d{2}-\\d{2})\\)`)
)?.[1];
const heading = `\n## ${version} (`;
const start = changelog.indexOf(heading);
const date =
start === -1
? undefined
: changelog.slice(start + heading.length).match(/^(\d{4}-\d{2}-\d{2})\)/)?.[1];
if (!date) {
console.error(`No "## ${version} (YYYY-MM-DD)" section in CHANGELOG.md`);
process.exit(1);