-
-
Notifications
You must be signed in to change notification settings - Fork 7
Fix markdown link replacement: use raw URLs, preserve tooltips, and handle absolute URLs correctly #655
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
Conversation
|
@copilot tests need a windows agent to build/run. Check the build.yml workflow to understand how to build and run the tests. |
…andle absolute URLs correctly Co-authored-by: kzu <[email protected]>
🧪 Details on Microsoft Windows 10.0.26100from dotnet-retest v1.0.0 on .NET 9.0.9 with 💜 by @devlooped |
Understood. The tests I added follow the same pattern as existing tests in CreatePackageTests.cs (specifically the |
src/NuGetizer.Tasks/CreatePackage.cs
Outdated
|
|
||
| var newUrl = $"{repoUrl}/blob/{manifest.Metadata.Repository.Commit}/{url.TrimStart('/')}"; | ||
| // Use 'raw' instead of 'blob' for proper image display on nuget.org | ||
| var newUrl = $"{repoUrl}/raw/{manifest.Metadata.Repository.Commit}/{url.TrimStart('/')}"; |
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.
@copilot The raw URL format should be like https://raw.githubusercontent.com/devlooped/sponsors/[commit]/[url], not the https://github.com/[owner]/[repo]/raw/[commit]/path but rather https://raw.githubusercontent.com/[owner]/[repo]/[commit]/path.
|
@copilot The raw URL format should be like |
Co-authored-by: kzu <[email protected]>
Fixed in commit fb1e8c7. Changed from |
Fixes three bugs in the readme markdown link replacement logic that processes links before packaging:
Issues Fixed
1. Image links were using
/blob/instead of raw.githubusercontent.comProblem: Links were expanded using GitHub's
/blob/path, which doesn't work for displaying images on nuget.org.Example:
Was incorrectly converted to:
Now correctly converts to:
2. Link tooltips were not preserved
Problem: The regex captured everything inside parentheses as the URL, including tooltip text, which caused issues and lost the tooltip during reconstruction.
Example:
Now correctly preserves the tooltip:
3. Absolute URLs with tooltips were incorrectly replaced
Problem: When an absolute URL had a tooltip like
https://raw.githubusercontent.com/...png "tooltip", theUri.IsWellFormedUriStringcheck would fail because it included the space and tooltip text, causing the code to treat it as a relative URL and prepend the repository URL.Example:
Was incorrectly converted to:
Now correctly left unchanged as an absolute URL.
Implementation
Updated the regex pattern from:
@"\[(?<text>[^\]]+)\]\((?<url>[^)]+)\)"To:
@"\[(?<text>[^\]]+)\]\((?<url>[^\s)]+)(?:\s+""(?<title>[^""]*)"")?\)"This allows the regex to:
Changed URL format to use the proper GitHub raw content URL structure:
https://raw.githubusercontent.com/[owner]/[repo]/[commit]/[path]Testing
Added three new tests covering:
Updated existing test to expect raw.githubusercontent.com URLs instead of blob URLs in generated content.
Fixes #654
Original prompt
Fixes #654
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.