Skip to content

Commit f4da070

Browse files
committed
bugfix-314-error-merging-release-branch-after-successful-deployment: Fix commit URL generation to properly encode owner and repository names. Added tests to verify URL encoding for special characters in commit links.
1 parent b637168 commit f4da070

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/utils/__tests__/comment_watermark.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,19 @@ describe('comment_watermark', () => {
2222
expect(w).toContain('github.com/o/r/commit/abc123');
2323
expect(w).toContain('This will update automatically on new commits');
2424
});
25+
26+
it('URL-encodes owner and repo in commit link when they contain special characters', () => {
27+
const w = getCommentWatermark({
28+
commitSha: 'abc123',
29+
owner: 'my.org',
30+
repo: 'my-repo',
31+
});
32+
expect(w).toContain('github.com/my.org/my-repo/commit/abc123');
33+
const w2 = getCommentWatermark({
34+
commitSha: 'def456',
35+
owner: 'org with spaces',
36+
repo: 'repo',
37+
});
38+
expect(w2).toContain('github.com/org%20with%20spaces/repo/commit/def456');
39+
});
2540
});

src/utils/comment_watermark.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface BugbotWatermarkOptions {
1515
}
1616

1717
function commitUrl(owner: string, repo: string, sha: string): string {
18-
return `https://github.com/${owner}/${repo}/commit/${sha}`;
18+
return `https://github.com/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/commit/${sha}`;
1919
}
2020

2121
export function getCommentWatermark(options?: BugbotWatermarkOptions): string {

0 commit comments

Comments
 (0)