-
Notifications
You must be signed in to change notification settings - Fork 1
fix: change pr link to redirect url #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,19 @@ export interface BundleAnalysis { | |
| }>; | ||
| } | ||
|
|
||
| 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; | ||
| } | ||
| } | ||
|
Comment on lines
+52
to
+63
|
||
|
|
||
| export function formatBytes(bytes: number): string { | ||
| if (bytes === 0) return '0 B'; | ||
|
|
||
|
|
@@ -210,7 +223,9 @@ export function generateProjectMarkdown( | |
|
|
||
| // Add PR links if available | ||
| if (baselinePRs && baselinePRs.length > 0) { | ||
| const prLinks = baselinePRs.map(pr => `[#${pr.number}](${pr.url})`).join(', '); | ||
| const prLinks = baselinePRs | ||
| .map(pr => `[#${pr.number}](${toGitHubRedirectUrl(pr.url)})`) | ||
| .join(', '); | ||
| baselineInfo += ` | **PR:** ${prLinks}`; | ||
| } | ||
|
|
||
|
|
@@ -247,7 +262,9 @@ export async function generateBundleAnalysisReport( | |
|
|
||
| // Add PR links if available | ||
| if (baselinePRs && baselinePRs.length > 0) { | ||
| const prLinks = baselinePRs.map(pr => `[#${pr.number}](${pr.url})`).join(', '); | ||
| const prLinks = baselinePRs | ||
| .map(pr => `[#${pr.number}](${toGitHubRedirectUrl(pr.url)})`) | ||
| .join(', '); | ||
| baselineInfo += ` | **PR:** ${prLinks}`; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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.