Skip to content

Commit bb792e0

Browse files
committed
fix(flatpak): read the changelog date without building a regex from input
1 parent 6cb7357 commit bb792e0

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎scripts/flatpak-metainfo-release.js‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ if (!version || !/^\d+\.\d+\.\d+/.test(version)) {
1515
}
1616

1717
const changelog = readFileSync('CHANGELOG.md', 'utf8');
18-
const date = changelog.match(
19-
new RegExp(`\\n## ${version.replaceAll('.', '\\.')} \\((\\d{4}-\\d{2}-\\d{2})\\)`)
20-
)?.[1];
18+
const heading = `\n## ${version} (`;
19+
const start = changelog.indexOf(heading);
20+
const date =
21+
start === -1
22+
? undefined
23+
: changelog.slice(start + heading.length).match(/^(\d{4}-\d{2}-\d{2})\)/)?.[1];
2124
if (!date) {
2225
console.error(`No "## ${version} (YYYY-MM-DD)" section in CHANGELOG.md`);
2326
process.exit(1);

0 commit comments

Comments
 (0)