diff --git a/lib/rules/fixes-url.js b/lib/rules/fixes-url.js index 2343481..b63edbe 100644 --- a/lib/rules/fixes-url.js +++ b/lib/rules/fixes-url.js @@ -1,6 +1,6 @@ const id = 'fixes-url' const github = new RegExp('^https://github\\.com/[\\w-]+/[\\w-]+/' + - '(issues|pull)/\\d+(#issuecomment-\\d+|#discussion_r\\d+)?$' + '(issues|pull)/\\d+(#issuecomment-\\d+|#discussion_r\\d+)?/?$' ) export default { diff --git a/lib/rules/pr-url.js b/lib/rules/pr-url.js index 823e644..e09af3d 100644 --- a/lib/rules/pr-url.js +++ b/lib/rules/pr-url.js @@ -1,5 +1,5 @@ const id = 'pr-url' -const prUrl = /^https:\/\/github\.com\/[\w-]+\/[\w-]+\/pull\/\d+$/ +const prUrl = /^https:\/\/github\.com\/[\w-]+\/[\w-]+\/pull\/\d+\/?$/ export default { id, diff --git a/test/rules/fixes-url.js b/test/rules/fixes-url.js index f728195..1ed7744 100644 --- a/test/rules/fixes-url.js +++ b/test/rules/fixes-url.js @@ -24,6 +24,8 @@ test('rule: fixes-url', (t) => { const valid = [ ['GitHub issue URL', '/~https://github.com/nodejs/node/issues/1234'], + ['GitHub issue URL with trailing slash', + '/~https://github.com/nodejs/node/issues/1234/'], ['GitHub issue URL containing hyphen', '/~https://github.com/nodejs/node-report/issues/1234'], ['GitHub issue URL containing hyphen with comment', diff --git a/test/rules/pr-url.js b/test/rules/pr-url.js index 27f2bdf..20bddcd 100644 --- a/test/rules/pr-url.js +++ b/test/rules/pr-url.js @@ -115,5 +115,28 @@ test('rule: pr-url', (t) => { Rule.validate(context) }) + t.test('valid URL with trailing slash', (tt) => { + tt.plan(7) + const url = '/~https://github.com/nodejs/node-report/pull/1234/' + const context = { + prUrl: url, + body: [ + '', + `PR-URL: ${url}` + ], + report: (opts) => { + tt.pass('called report') + tt.equal(opts.id, 'pr-url', 'id') + tt.equal(opts.message, VALID_PR_URL, 'message') + tt.equal(opts.string, url, 'string') + tt.equal(opts.line, 1, 'line') + tt.equal(opts.column, 8, 'column') + tt.equal(opts.level, 'pass', 'level') + } + } + + Rule.validate(context) + }) + t.end() })