From 968275fcb1d4e3941c542f0cfbe4f227f19ee94d Mon Sep 17 00:00:00 2001 From: RafaelGSS Date: Wed, 10 Jul 2024 11:42:14 -0300 Subject: [PATCH 1/3] fix: add support to trailing slash in PR-URL --- lib/rules/pr-url.js | 2 +- test/rules/pr-url.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) 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/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() }) From 9ce9c1e098ae37e75adcbd646ef048d6e2fc17b7 Mon Sep 17 00:00:00 2001 From: RafaelGSS Date: Wed, 10 Jul 2024 11:44:09 -0300 Subject: [PATCH 2/3] fix: add support to trailing slash in Fixes --- lib/rules/fixes-url.js | 2 +- test/rules/fixes-url.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/rules/fixes-url.js b/lib/rules/fixes-url.js index 2343481..619a10e 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/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', From 729fa8e4373f38b9a066f92a2cb2ed675b4fce8c Mon Sep 17 00:00:00 2001 From: Rafael Gonzaga Date: Wed, 10 Jul 2024 11:59:00 -0300 Subject: [PATCH 3/3] Update lib/rules/fixes-url.js Co-authored-by: Rich Trott --- lib/rules/fixes-url.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rules/fixes-url.js b/lib/rules/fixes-url.js index 619a10e..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 {