Conversation
Rsdoctor Bundle Diff AnalysisFound 2 projects in monorepo, 0 projects with changes. 📊 Quick Summary
Generated by Rsdoctor GitHub Action |
There was a problem hiding this comment.
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
toGitHubRedirectUrlhelper function to convert GitHub URLs to use redirect.github.com - Updated PR link generation in
generateProjectMarkdownandgenerateBundleAnalysisReportto 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; |
There was a problem hiding this comment.
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.
| if (!url) return url; | |
| if (!url) return ''; |
src/index.ts
Outdated
| // 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`; | ||
|
|
There was a problem hiding this comment.
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.
| // 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`; | |
| 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; | ||
| } | ||
| } |
There was a problem hiding this comment.
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.
This reverts commit 572b0a8.
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:
toGitHubRedirectUrlutility function insrc/report.tsto convert standard GitHub PR URLs toredirect.github.comURLs, preventing GitHub from auto-associating PR references in comments.generateProjectMarkdownandgenerateBundleAnalysisReportfunctions insrc/report.tsto use the new redirect URL utility, ensuring all PR links in reports use the safer redirect format. [1] [2]processSingleFileinsrc/index.tsto include an example PR/MR link using the redirect URL format, further illustrating the new approach and preventing unintended associations.