From f1b374a3593e1b7b162975ccd50bdda542feae1b 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 input if not long enough Recent PR[1] didn't take in account very small subjects. [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 2a30819b3aa..e3d2e762eb8 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; }