Fix PR links to use web URLs instead of API URLs#5454
Merged
Conversation
Co-authored-by: premun <[email protected]>
Co-authored-by: premun <[email protected]>
premun
reviewed
Nov 10, 2025
Copilot
AI
changed the title
Make active PR links in subscription page go to HTML URI
Fix PR links to use web URLs instead of API URLs
Nov 10, 2025
Address review feedback to check if the PR URL itself is an Azure DevOps URL before extracting org/repoName, rather than checking the subscription's target repository type. Co-authored-by: premun <[email protected]>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds test coverage for the TurnApiUrlToWebsite private method in PullRequestController and updates the ToTrackedPullRequest method to use this URL conversion function. The changes ensure that API URLs for pull requests are converted to their web equivalents for both GitHub and Azure DevOps.
- Adds comprehensive unit tests for URL conversion from API format to web format
- Updates
ToTrackedPullRequestto convert PR URLs using organization and repository information - Extracts Azure DevOps organization and repository names to support proper URL conversion
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 10 comments.
| File | Description |
|---|---|
| test/ProductConstructionService.Api.Tests/PullRequestUrlConversionTests.cs | Adds new test file with three test methods covering GitHub API URL conversion, Azure DevOps API URL conversion, and handling of non-API URLs |
| src/ProductConstructionService/ProductConstructionService.Api/Api/v2020_02_20/Controllers/PullRequestController.cs | Updates ToTrackedPullRequest to extract org/repo information and use TurnApiUrlToWebsite for PR URL conversion |
Comments suppressed due to low confidence (2)
src/ProductConstructionService/ProductConstructionService.Api/Api/v2020_02_20/Controllers/PullRequestController.cs:196
- Missing space before concatenation operator. The line should be
orgName + \"-\" + repoNamefor consistent formatting. Additionally, there's a critical bug:orgNamecan be null (line 213), but it's used here without null checking when concatenating strings. This will result in a literal "null-" prefix in the URL instead of a proper null check.
WellKnownIds[match.Groups["repo"].Value] = orgName + "-" +repoName;
src/ProductConstructionService/ProductConstructionService.Api/Api/v2020_02_20/Controllers/PullRequestController.cs:224
- Generic catch clause.
catch
{
// Repos which do not conform to usual naming will not be handled
}
- Extract reflection-based method lookup to SetUp method - Add helper method InvokeTurnApiUrlToWebsite with named parameters for clarity - Add XML documentation explaining the parameters Co-authored-by: premun <[email protected]>
dkurepa
approved these changes
Nov 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR links on the subscriptions page were displaying GitHub API URLs (
https://api.github.com/repos/dotnet/dotnet/pulls/3205) instead of web URLs (https://github.com/dotnet/dotnet/pull/3205).Changes:
ToTrackedPullRequestinPullRequestController.csto apply the existingTurnApiUrlToWebsitemethod to PR URLs before returning themAzdoApiPrUrlRegex().IsMatch(pr.Url)to determine if org/repoName extraction is needed for Azure DevOps URLsThe
TurnApiUrlToWebsitemethod was already being used for source repository URLs but wasn't applied to the PR URL field itself.Fixes #5453
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.