@@ -61,9 +61,9 @@ const createUserLink = (user: GitHubUser) =>
6161const sanitizeMarkdown = ( text : string ) : string => {
6262 return text
6363 // 移除代码块
64- // .replace(/```[\s\S]*?```/g, '[代码块]')
64+ . replace ( / ` ` ` [ \s \S ] * ?` ` ` / g, '[代码块]' )
6565 // 移除行内代码
66- // .replace(/`[^`]+`/g, (match) => match.slice(1, -1))
66+ . replace ( / ` [ ^ ` ] + ` / g, ( match ) => match . slice ( 1 , - 1 ) )
6767 // 将图片转换为链接文本
6868 . replace ( / ! \[ ( [ ^ \] ] * ) \] \( ( [ ^ ) ] + ) \) / g, '🖼️ [$1]($2)' )
6969 // 将 ### 标题转换为加粗
@@ -104,7 +104,6 @@ const eventHandlers: Record<string, EventHandler> = {
104104 actor,
105105 } ) => {
106106 const commitUrl = head_commit ?. url || `${ server_url } /${ repository } /tree/${ ref_name } ` ;
107- const commitId = head_commit ?. id ?. slice ( 0 , 7 ) || 'n/a' ;
108107 const commitMessage = head_commit ?. message || 'Create/Delete/Update Branch (No head commit)' ;
109108
110109 return {
@@ -113,7 +112,7 @@ const eventHandlers: Record<string, EventHandler> = {
113112 {
114113 tag : 'markdown' ,
115114 content : [
116- createContentItem ( '提交链接:' , createLink ( commitUrl , commitId ) ) ,
115+ createContentItem ( '提交链接:' , createLink ( commitUrl ) ) ,
117116 createContentItem ( '代码分支:' , createLink ( `${ server_url } /${ repository } /tree/${ ref_name } ` , ref_name ) ) ,
118117 createContentItem ( '提交作者:' , createLink ( `${ server_url } /${ actor } ` , actor ) ) ,
119118 createContentItem ( '提交信息:' , commitMessage ) ,
@@ -129,7 +128,7 @@ const eventHandlers: Record<string, EventHandler> = {
129128 {
130129 tag : 'markdown' ,
131130 content : [
132- createContentItem ( '链接:' , createLink ( issue ! . html_url , `# ${ issue ! . number } ` ) ) ,
131+ createContentItem ( '链接:' , createLink ( issue ! . html_url ) ) ,
133132 createContentItem ( '作者:' , createUserLink ( issue ! . user ! ) ) ,
134133 createContentItem ( '指派:' , issue ?. assignee ? createUserLink ( issue . assignee ) : '无' ) ,
135134 createContentItem ( '标签:' , issue ?. labels ?. map ( ( { name } ) => name ) . join ( ', ' ) || '无' ) ,
@@ -146,7 +145,7 @@ const eventHandlers: Record<string, EventHandler> = {
146145 {
147146 tag : 'markdown' ,
148147 content : [
149- createContentItem ( '链接:' , createLink ( pull_request ! . html_url , `# ${ pull_request ! . number } ` ) ) ,
148+ createContentItem ( '链接:' , createLink ( pull_request ! . html_url ) ) ,
150149 createContentItem ( '作者:' , createUserLink ( pull_request ! . user ) ) ,
151150 createContentItem ( '指派:' , pull_request ?. assignee ? createUserLink ( pull_request . assignee ) : '无' ) ,
152151 createContentItem ( '标签:' , pull_request ?. labels ?. map ( ( { name } ) => name ) . join ( ', ' ) || '无' ) ,
@@ -163,7 +162,7 @@ const eventHandlers: Record<string, EventHandler> = {
163162 {
164163 tag : 'markdown' ,
165164 content : [
166- createContentItem ( '链接:' , createLink ( discussion ! . html_url , `# ${ discussion ! . number } ` ) ) ,
165+ createContentItem ( '链接:' , createLink ( discussion ! . html_url ) ) ,
167166 createContentItem ( '作者:' , createUserLink ( discussion ! . user as GitHubUser ) ) ,
168167 createContentItem ( '描述:' , discussion ?. body || '无' ) ,
169168 ] . join ( '\n' ) ,
@@ -177,7 +176,7 @@ const eventHandlers: Record<string, EventHandler> = {
177176 {
178177 tag : 'markdown' ,
179178 content : [
180- createContentItem ( '链接:' , createLink ( comment ! . html_url , '查看评论' ) ) ,
179+ createContentItem ( '链接:' , createLink ( comment ! . html_url ) ) ,
181180 createContentItem ( '作者:' , createUserLink ( comment ! . user ! ) ) ,
182181 createContentItem ( '描述:' , comment ?. body || '无' ) ,
183182 ] . join ( '\n' ) ,
@@ -191,7 +190,7 @@ const eventHandlers: Record<string, EventHandler> = {
191190 {
192191 tag : 'markdown' ,
193192 content : [
194- createContentItem ( '链接:' , createLink ( comment ! . html_url , '查看评论' ) ) ,
193+ createContentItem ( '链接:' , createLink ( comment ! . html_url ) ) ,
195194 createContentItem ( '作者:' , createUserLink ( comment ! . user ! ) ) ,
196195 createContentItem ( '描述:' , comment ?. body || '无' ) ,
197196 ] . join ( '\n' ) ,
@@ -205,7 +204,7 @@ const eventHandlers: Record<string, EventHandler> = {
205204 {
206205 tag : 'markdown' ,
207206 content : [
208- createContentItem ( '链接:' , createLink ( release ! . html_url , release ! . tag_name ) ) ,
207+ createContentItem ( '链接:' , createLink ( release ! . html_url ) ) ,
209208 createContentItem ( '作者:' , createUserLink ( release ! . author ) ) ,
210209 createContentItem ( '描述:' , release ?. body || '无' ) ,
211210 ] . join ( '\n' ) ,
@@ -219,7 +218,7 @@ const eventHandlers: Record<string, EventHandler> = {
219218 {
220219 tag : 'markdown' ,
221220 content : [
222- createContentItem ( '链接:' , createLink ( comment ! . html_url , '查看评论' ) ) ,
221+ createContentItem ( '链接:' , createLink ( comment ! . html_url ) ) ,
223222 createContentItem ( '作者:' , createUserLink ( comment ! . user ! ) ) ,
224223 createContentItem ( 'PR:' , createLink ( pull_request ! . html_url , `#${ pull_request ! . number } ` ) ) ,
225224 createContentItem ( '评论:' , comment ?. body || '无' ) ,
0 commit comments