File tree Expand file tree Collapse file tree 4 files changed +27
-2
lines changed
Expand file tree Collapse file tree 4 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 11const id = 'fixes-url'
22const github = new RegExp ( '^https://github\\.com/[\\w-]+/[\\w-]+/' +
3- '(issues|pull)/\\d+(#issuecomment-\\d+|#discussion_r\\d+)?$'
3+ '(issues|pull)/\\d+(#issuecomment-\\d+|#discussion_r\\d+)?/? $'
44)
55
66export default {
Original file line number Diff line number Diff line change 11const id = 'pr-url'
2- const prUrl = / ^ h t t p s : \/ \/ g i t h u b \. c o m \/ [ \w - ] + \/ [ \w - ] + \/ p u l l \/ \d + $ /
2+ const prUrl = / ^ h t t p s : \/ \/ g i t h u b \. c o m \/ [ \w - ] + \/ [ \w - ] + \/ p u l l \/ \d + \/ ? $ /
33
44export default {
55 id,
Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ test('rule: fixes-url', (t) => {
2424 const valid = [
2525 [ 'GitHub issue URL' ,
2626 'https://github.com/nodejs/node/issues/1234' ] ,
27+ [ 'GitHub issue URL with trailing slash' ,
28+ 'https://github.com/nodejs/node/issues/1234/' ] ,
2729 [ 'GitHub issue URL containing hyphen' ,
2830 'https://github.com/nodejs/node-report/issues/1234' ] ,
2931 [ 'GitHub issue URL containing hyphen with comment' ,
Original file line number Diff line number Diff line change @@ -115,5 +115,28 @@ test('rule: pr-url', (t) => {
115115 Rule . validate ( context )
116116 } )
117117
118+ t . test ( 'valid URL with trailing slash' , ( tt ) => {
119+ tt . plan ( 7 )
120+ const url = 'https://github.com/nodejs/node-report/pull/1234/'
121+ const context = {
122+ prUrl : url ,
123+ body : [
124+ '' ,
125+ `PR-URL: ${ url } `
126+ ] ,
127+ report : ( opts ) => {
128+ tt . pass ( 'called report' )
129+ tt . equal ( opts . id , 'pr-url' , 'id' )
130+ tt . equal ( opts . message , VALID_PR_URL , 'message' )
131+ tt . equal ( opts . string , url , 'string' )
132+ tt . equal ( opts . line , 1 , 'line' )
133+ tt . equal ( opts . column , 8 , 'column' )
134+ tt . equal ( opts . level , 'pass' , 'level' )
135+ }
136+ }
137+
138+ Rule . validate ( context )
139+ } )
140+
118141 t . end ( )
119142} )
You can’t perform that action at this time.
0 commit comments