diff --git a/__tests__/unit/actions/lib/searchAndReplaceSpecialAnnotation.test.js b/__tests__/unit/actions/lib/searchAndReplaceSpecialAnnotation.test.js index 227140a8..0824c233 100644 --- a/__tests__/unit/actions/lib/searchAndReplaceSpecialAnnotation.test.js +++ b/__tests__/unit/actions/lib/searchAndReplaceSpecialAnnotation.test.js @@ -36,4 +36,22 @@ describe('searchAndReplaceSpecialAnnotations', () => { } expect(searchAndReplaceSpecialAnnotations('this is @author', payload)).toBe('this is creator') }) + + test('@@author is replaced by @payload.user.login', () => { + const payload = { + user: { + login: 'creator' + } + } + expect(searchAndReplaceSpecialAnnotations('this is @@author', payload)).toBe('this is @creator') + }) + + test('replaces annotation anywhere in the text', () => { + const payload = { + user: { + login: 'creator' + } + } + expect(searchAndReplaceSpecialAnnotations('this is something@author speaking', payload)).toBe('this is somethingcreator speaking') + }) }) diff --git a/lib/actions/lib/searchAndReplaceSpecialAnnotation.js b/lib/actions/lib/searchAndReplaceSpecialAnnotation.js index 45dbce00..b3edb823 100644 --- a/lib/actions/lib/searchAndReplaceSpecialAnnotation.js +++ b/lib/actions/lib/searchAndReplaceSpecialAnnotation.js @@ -6,11 +6,11 @@ const searchAndReplaceSpecialAnnotations = (template, payload) => { let newTemplate = template for (const annotation of Object.keys(SPECIAL_ANNOTATION)) { - const specialAnnotationRegex = new RegExp(`([^\\\\])${annotation}`) + const specialAnnotationRegex = new RegExp(`(?