Skip to content

Commit 916a7b3

Browse files
committed
fix
1 parent e522e77 commit 916a7b3

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

tests/integration/issue_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,3 +607,22 @@ func TestUpdateIssueDeadline(t *testing.T) {
607607

608608
assert.EqualValues(t, "2022-04-06", apiIssue.Deadline.Format("2006-01-02"))
609609
}
610+
611+
func TestIssueReferenceURL(t *testing.T) {
612+
defer tests.PrepareTestEnv(t)()
613+
session := loginUser(t, "user2")
614+
615+
issue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 1})
616+
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: issue.RepoID})
617+
618+
req := NewRequest(t, "GET", fmt.Sprintf("%s/issues/%d", repo.FullName(), issue.Index))
619+
resp := session.MakeRequest(t, req, http.StatusOK)
620+
htmlDoc := NewHTMLParser(t, resp.Body)
621+
622+
// the "reference" uses relative URLs, then JS code will convert them to absolute URLs for current origin, in case users are using multiple domains
623+
ref, _ := htmlDoc.Find(`.timeline-item.comment.first .reference-issue`).Attr("data-reference")
624+
assert.EqualValues(t, "/user2/repo1/issues/1#issue-1", ref)
625+
626+
ref, _ = htmlDoc.Find(`.timeline-item.comment:not(.first) .reference-issue`).Attr("data-reference")
627+
assert.EqualValues(t, "/user2/repo1/issues/1#issuecomment-2", ref)
628+
}

web_src/js/features/repo-issue.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {showTemporaryTooltip, createTippy} from '../modules/tippy.js';
44
import {hideElem, showElem, toggleElem} from '../utils/dom.js';
55
import {setFileFolding} from './file-fold.js';
66
import {getComboMarkdownEditor, initComboMarkdownEditor} from './comp/ComboMarkdownEditor.js';
7+
import {toAbsoluteUrl} from "../utils.js";
78

89
const {appSubUrl, csrfToken} = window.config;
910

@@ -526,7 +527,7 @@ export function initRepoIssueReferenceIssue() {
526527
const $this = $(this);
527528
const content = $(`#${$this.data('target')}`).text();
528529
const poster = $this.data('poster-username');
529-
const reference = $this.data('reference');
530+
const reference = toAbsoluteUrl($this.data('reference'));
530531
const $modal = $($this.data('modal'));
531532
$modal.find('textarea[name="content"]').val(`${content}\n\n_Originally posted by @${poster} in ${reference}_`);
532533
$modal.modal('show');

0 commit comments

Comments
 (0)