Skip to content

Commit f0a3d0c

Browse files
Rename username with mention
1 parent 0611c1e commit f0a3d0c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/node/plugins/transformers/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import type { GitHubLinkifyTransformer } from '../../types/transformer.js'
22

3-
import { usernameCompact, usernameExpand } from './username.js'
3+
import { mentionCompact, mentionExpand } from './mention.js'
44
import { pullRequestCompact, pullRequestExpand } from './pull-request.js'
55
import { compareCompact, compareExpand } from './compare.js'
66
import { commitCompact, commitExpand } from './commit.js'
77

88
const compact = [
9-
usernameCompact,
9+
mentionCompact,
1010
pullRequestCompact,
1111
compareCompact,
1212
commitCompact
1313
]
1414

1515
const expand = [
16-
usernameExpand,
16+
mentionExpand,
1717
pullRequestExpand,
1818
compareExpand,
1919
commitExpand
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { regex } from '../regex.js'
33
import { template } from '../template.js'
44
import { url } from '../url.js'
55

6-
export const usernameCompact: GitHubLinkifyTransformer = (text: string, repo: string) => {
7-
const replacer = (value, item) => value.replace(item[0], template('username', item[1]))
6+
export const mentionCompact: GitHubLinkifyTransformer = (text: string, repo: string) => {
7+
const replacer = (value, item) => value.replace(item[0], template('mention', item[1]))
88

99
text = regex(text, /<\s*a.+@([a-zA-Z][\w\d\-_]*).+<\/\s*a\s*>/g, replacer)
1010
text = regex(text, /\[[\s`@]*[\w\d\-]+[\s`]*]\(https:\/\/github\.com\/([\w\d\-]+)\/?\)/g, replacer)
@@ -13,10 +13,10 @@ export const usernameCompact: GitHubLinkifyTransformer = (text: string, repo: st
1313
return text
1414
}
1515

16-
export const usernameExpand: GitHubLinkifyTransformer = (text: string, repo: string) => {
16+
export const mentionExpand: GitHubLinkifyTransformer = (text: string, repo: string) => {
1717
const replacer = (value, item) => value.replace(item[0], url(repo, `@${ item[1] }`, item[1]))
1818

19-
text = regex(text, /::username::([\w\d\-_]+)::/g, replacer)
19+
text = regex(text, /::mention::([\w\d\-_]+)::/g, replacer)
2020

2121
return text
2222
}

0 commit comments

Comments
 (0)