Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/jira/util/jira-client-util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,27 @@ describe("Jira util", () => {
expect(result).toBe(rendered);
});

it("should not add reference to existing markdown links", () => {
const { source, rendered } = loadFixture("existing-markdown-links");
const issues = [
{
key: "TEST-2019",
fields: {
summary: "Example Issue"
}
},
{
key: "TEST-2020",
fields: {
summary: "Another Example Issue"
}
}
];

const result = util.addJiraIssueLinks(source, issues);
expect(result).toBe(rendered);
});

it("should not linkify Jira references to invalid issues", () => {
const text = "Should not linkify [TEST-123] as a link";
const issues = [];
Expand Down
2 changes: 1 addition & 1 deletion src/util/jira-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const jiraIssueRegex = (): RegExp => {
* This regex is used when adding links to Jira issues in GitHub PR issue/descriptions.
*/
export const jiraIssueInSquareBracketsRegex = (): RegExp => {
return /(^|[^A-Z\d])\[([A-Z][A-Z\d]{1,255}-[1-9]\d{0,255})\]/giu;
return /(^|[^A-Z\d])\[([A-Z][A-Z\d]{1,255}-[1-9]\d{0,255})\](?!\()/giu;
};

/**
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/text/existing-markdown-links.rendered.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Should add a reference for [TEST-2019], but not for [TEST-2020](http://example.com/browse/TEST-2020?focusedCommentId=123).

[TEST-2019]: http://example.com/browse/TEST-2019
1 change: 1 addition & 0 deletions test/fixtures/text/existing-markdown-links.source.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Should add a reference for [TEST-2019], but not for [TEST-2020](http://example.com/browse/TEST-2020?focusedCommentId=123).