Commit 2963862

Andrew J.Swan <ajs.blackhole@gmail.com>
2025-01-22 18:32:30
Removed unnecessary prefixes to match Conventional Commits (#113)
* Add `add, update, merge, bump, pull request` to `ignore conventional commit` regex * Remove `add, update` from `ignore conventional commit` regex * Revert regex for `Conventional Commits` correspondence
1 parent 3265dc1
Changed files (2)
badges/favorite-word/favorite-word.test.ts
@@ -24,18 +24,18 @@ describe('favorite-word', () => {
           expect(splitWithoutTooFrequentWords(`${prefix}: hello world`)).toEqual(['hello', 'world'])
         })
         it(`ignores "${prefix}" without space after it`, () => {
-          expect(splitWithoutTooFrequentWords(`${prefix}:hello world`)).toEqual([':hello', 'world'])
+          expect(splitWithoutTooFrequentWords(`${prefix}:hello world`)).toEqual(['hello', 'world'])
         })
         it(`ignores "${prefix}" with exclamation mark`, () => {
           expect(splitWithoutTooFrequentWords(`${prefix}!: hello world`)).toEqual(['hello', 'world'])
         })
         it(`ignores "${prefix}" with scope`, () => {
-          expect(splitWithoutTooFrequentWords(`${prefix}(world): hello`)).toEqual(['(world):', 'hello'])
+          expect(splitWithoutTooFrequentWords(`${prefix}(world): hello`)).toEqual(['hello'])
         })
         it(`don't ignore "${prefix}" if not at the beginning`, () => {
 	      const expectedPrefix = `${prefix}:`.toLowerCase().split(' ')
 	      expectedPrefix.unshift('hello')
-          expect(splitWithoutTooFrequentWords(`hello ${prefix}:`)).toEqual(['hello'])
+          expect(splitWithoutTooFrequentWords(`hello ${prefix}:`)).toEqual(expectedPrefix)
         })
 	  })
     }
badges/favorite-word/favorite-word.ts
@@ -37,7 +37,7 @@ export function splitWithoutTooFrequentWords(msg: string) {
       .toLowerCase()
       // remove conventional commit prefixes as they would outweigh other words
       .replace(
-        /(?<=\s|^)(breaking changes?|build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(?=\s|:|!|\(|$)/gm,
+        /^(breaking changes?|build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(?:\(.*?\))?!?:/gm,
         '',
       )
       .split(/\s+/)