@@ -227,6 +227,62 @@ func TestFindAllIssueReferences(t *testing.T) {
227227
228228 testFixtures (t , fixtures , "default" )
229229
230+ // Test closing/reopening keywords with URLs (issue #27549)
231+ // Uses the same AppURL as testFixtures (https://gitea.com:3000/)
232+ urlFixtures := []testFixture {
233+ {
234+ "Closes [this issue](https://gitea.com:3000/user/repo/issues/123)" ,
235+ []testResult {
236+ {123 , "user" , "repo" , "123" , false , XRefActionCloses , nil , & RefSpan {Start : 0 , End : 6 }, "" },
237+ },
238+ },
239+ {
240+ "This fixes [#456](https://gitea.com:3000/org/project/issues/456)" ,
241+ []testResult {
242+ {456 , "org" , "project" , "456" , false , XRefActionCloses , nil , & RefSpan {Start : 5 , End : 10 }, "" },
243+ },
244+ },
245+ {
246+ "Reopens [PR](https://gitea.com:3000/owner/repo/pulls/789)" ,
247+ []testResult {
248+ {789 , "owner" , "repo" , "789" , true , XRefActionReopens , nil , & RefSpan {Start : 0 , End : 7 }, "" },
249+ },
250+ },
251+ {
252+ "See [issue](https://gitea.com:3000/user/repo/issues/100) but closes [another](https://gitea.com:3000/user/repo/issues/200)" ,
253+ []testResult {
254+ {100 , "user" , "repo" , "100" , false , XRefActionNone , nil , nil , "" },
255+ {200 , "user" , "repo" , "200" , false , XRefActionCloses , nil , & RefSpan {Start : 61 , End : 67 }, "" },
256+ },
257+ },
258+ }
259+
260+ testFixtures (t , urlFixtures , "url-keywords" )
261+
262+ // Test bare URLs (not markdown links) with closing keywords
263+ // These use FindAllIssueReferences (non-markdown) which converts full URLs to short refs first
264+ setting .AppURL = "https://gitea.com:3000/"
265+ bareURLTests := []struct {
266+ name string
267+ input string
268+ expected XRefAction
269+ }{
270+ {"Fixes bare URL" , "Fixes https://gitea.com:3000/org/project/issues/456" , XRefActionCloses },
271+ {"Fixes with colon" , "Fixes: https://gitea.com:3000/org/project/issues/456" , XRefActionCloses },
272+ {"Closes bare URL" , "Closes https://gitea.com:3000/user/repo/issues/123" , XRefActionCloses },
273+ {"Closes with colon" , "Closes: https://gitea.com:3000/user/repo/issues/123" , XRefActionCloses },
274+ }
275+
276+ for _ , tt := range bareURLTests {
277+ t .Run (tt .name , func (t * testing.T ) {
278+ refs := FindAllIssueReferences (tt .input )
279+ assert .Len (t , refs , 1 , "Expected 1 reference for: %s" , tt .input )
280+ if len (refs ) > 0 {
281+ assert .Equal (t , tt .expected , refs [0 ].Action , "Expected action %v for: %s" , tt .expected , tt .input )
282+ }
283+ })
284+ }
285+
230286 type alnumFixture struct {
231287 input string
232288 issue string
0 commit comments