File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -218,4 +218,39 @@ describe('render template', () => {
218218 expect ( output ) . toMatchInlineSnapshot ( '"abc ABC"' )
219219 } )
220220 } )
221+
222+ describe ( 'semantic prefix replacers (issue #1228)' , ( ) => {
223+ const multilineBody = [
224+ "# What's Changed" ,
225+ '' ,
226+ '* feat(foo): Add feature (#1) @user' ,
227+ '* fix: Bug fix (#2) @user' ,
228+ '* ci(deps): Update dependencies (#3) @user' ,
229+ '* chore: Regular maintenance (#4) @user' ,
230+ ] . join ( '\n' )
231+
232+ it ( 'regex using ^ with multiline flag AND accounting for the "* " prefix strips semantic prefixes' , ( ) => {
233+ // An alternative that preserves the `^` intent: capture the `* ` prefix
234+ // together and put it back in the replacement.
235+ const output = renderTemplate ( {
236+ template : multilineBody ,
237+ object : { } ,
238+ replacers : [
239+ {
240+ search : / ^ ( \* ) ( f i x | f e a t | c i ) ( \( .+ ?\) ) ? : / gm,
241+ replace : '$1' ,
242+ } ,
243+ ] ,
244+ } )
245+
246+ expect ( output ) . toMatchInlineSnapshot ( `
247+ "# What's Changed
248+
249+ * Add feature (#1) @user
250+ * Bug fix (#2) @user
251+ * Update dependencies (#3) @user
252+ * chore: Regular maintenance (#4) @user"
253+ ` )
254+ } )
255+ } )
221256} )
You can’t perform that action at this time.
0 commit comments