Skip to content

Commit 67c75e0

Browse files
RafaelGSSTrott
andauthored
fix: support trailing slash (#120)
* fix: add support to trailing slash in PR-URL * fix: add support to trailing slash in Fixes * Update lib/rules/fixes-url.js Co-authored-by: Rich Trott <[email protected]> --------- Co-authored-by: Rich Trott <[email protected]>
1 parent 006aedd commit 67c75e0

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

lib/rules/fixes-url.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const id = 'fixes-url'
22
const 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

66
export default {

lib/rules/pr-url.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const id = 'pr-url'
2-
const prUrl = /^https:\/\/github\.com\/[\w-]+\/[\w-]+\/pull\/\d+$/
2+
const prUrl = /^https:\/\/github\.com\/[\w-]+\/[\w-]+\/pull\/\d+\/?$/
33

44
export default {
55
id,

test/rules/fixes-url.js

+2
Original file line numberDiff line numberDiff 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',

test/rules/pr-url.js

+23
Original file line numberDiff line numberDiff 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
})

0 commit comments

Comments
 (0)