Skip to content

fix: change pr link to redirect url#28

Merged
yifancong merged 3 commits intomainfrom
fix/change-pr-link-redirect
Jan 28, 2026
Merged

fix: change pr link to redirect url#28
yifancong merged 3 commits intomainfrom
fix/change-pr-link-redirect

Conversation

@yifancong
Copy link
Copy Markdown
Contributor

@yifancong yifancong commented Jan 28, 2026

fix: change pr link to redirect url

This pull request improves how pull request (PR) links are displayed in bundle analysis reports and comments, ensuring that GitHub does not auto-associate these links with issues or PRs by using redirect URLs. The changes introduce a utility function for generating redirect links and update all PR link generation to use this function.

Improvements to PR Link Handling:

  • Added a toGitHubRedirectUrl utility function in src/report.ts to convert standard GitHub PR URLs to redirect.github.com URLs, preventing GitHub from auto-associating PR references in comments.
  • Updated PR link generation in both generateProjectMarkdown and generateBundleAnalysisReport functions in src/report.ts to use the new redirect URL utility, ensuring all PR links in reports use the safer redirect format. [1] [2]
  • Modified the comment body in processSingleFile in src/index.ts to include an example PR/MR link using the redirect URL format, further illustrating the new approach and preventing unintended associations.

Copilot AI review requested due to automatic review settings January 28, 2026 08:12
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 28, 2026

Rsdoctor Bundle Diff Analysis

Found 2 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Change
rsbuild-demo 190.4 KB 0
rsbuild-demo2 190.9 KB 0

Generated by Rsdoctor GitHub Action

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to fix how PR links are redirected by using redirect.github.com instead of direct GitHub URLs to avoid GitHub's auto-association of PR references in comments.

Changes:

  • Added a new toGitHubRedirectUrl helper function to convert GitHub URLs to use redirect.github.com
  • Updated PR link generation in generateProjectMarkdown and generateBundleAnalysisReport to use the new redirect URL function
  • Added test/debug code showing an "Example PR/MR" link (appears to be unintentional debug code left in)

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/report.ts Added toGitHubRedirectUrl function and applied it to PR URLs in baseline info sections
src/index.ts Applied redirect URL logic to example PR link (appears to be test code)
dist/index.js Compiled JavaScript output with all changes from source files, including test code

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

function toGitHubRedirectUrl(url: string): string {
// Keep link clickable but avoid GitHub auto-associating PR references in comments.
// Example: https://github.com/org/repo/pull/123 -> https://redirect.github.com/org/repo/pull/123
if (!url) return url;
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function returns the falsy url value (undefined, null, or empty string) when the input is falsy. This can cause issues downstream where a string is expected. Consider returning an empty string explicitly or throwing an error for invalid inputs.

Suggested change
if (!url) return url;
if (!url) return '';

Copilot uses AI. Check for mistakes.
src/index.ts Outdated
Comment on lines 441 to 444
// Example PR/MR link (use redirect.github.com to avoid auto-association)
const repoSlug = process.env.GITHUB_REPOSITORY || 'OWNER/REPO';
commentBody += `> 🧪 **Example PR/MR:** [#19](https://redirect.github.com/${repoSlug}/pull/19)\n\n`;

Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be test or debug code that should not be included in production. The hardcoded "Example PR/MR" link with "#19" will be added to every PR comment generated by this action, which is confusing and unprofessional for end users. This code should be removed before merging.

Suggested change
// Example PR/MR link (use redirect.github.com to avoid auto-association)
const repoSlug = process.env.GITHUB_REPOSITORY || 'OWNER/REPO';
commentBody += `> 🧪 **Example PR/MR:** [#19](https://redirect.github.com/${repoSlug}/pull/19)\n\n`;

Copilot uses AI. Check for mistakes.
Comment on lines +52 to +63
function toGitHubRedirectUrl(url: string): string {
// Keep link clickable but avoid GitHub auto-associating PR references in comments.
// Example: https://github.com/org/repo/pull/123 -> https://redirect.github.com/org/repo/pull/123
if (!url) return url;
if (url.startsWith('https://redirect.github.com/')) return url;
try {
const u = new URL(url);
return `https://redirect.github.com${u.pathname}${u.search}${u.hash}`;
} catch {
return url;
}
}
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new toGitHubRedirectUrl function lacks test coverage. Given that other functions in this file have comprehensive test coverage (as seen in src/tests/report.test.ts), this function should have tests covering edge cases such as empty strings, null values, invalid URLs, URLs that already use redirect.github.com, and URLs with query parameters and hashes.

Copilot uses AI. Check for mistakes.
@yifancong yifancong changed the title Fix/change pr link redirect fix: change pr link to redirect url Jan 28, 2026
This reverts commit 572b0a8.
@yifancong yifancong merged commit 71406dd into main Jan 28, 2026
1 check passed
@yifancong yifancong deleted the fix/change-pr-link-redirect branch January 28, 2026 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants