From 599106047d50aa09e1e00b83d747b6f563aa8e52 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Sat, 20 Jan 2024 20:57:07 +0800 Subject: [PATCH] fix: avoid slicing header if not long enough Recent PR[1] didn't take in account very small subjects in subject-full-stop rule. [1] https://github.com/conventional-changelog/commitlint/pull/3839 --- @commitlint/rules/src/subject-full-stop.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/@commitlint/rules/src/subject-full-stop.ts b/@commitlint/rules/src/subject-full-stop.ts index 2a30819b3a..e3d2e762eb 100644 --- a/@commitlint/rules/src/subject-full-stop.ts +++ b/@commitlint/rules/src/subject-full-stop.ts @@ -15,7 +15,8 @@ export const subjectFullStop: SyncRule = ( const negated = when === 'never'; let hasStop = input[input.length - 1] === value; - if (input.slice(-3) === '...') { + let ellipsis = '...'; + if (input.length > ellipsis.length && input.slice(-ellipsis.length) === ellipsis) { hasStop = false; }