Fix author parsing in GitHub URLs with path-based author filters#282
Fix author parsing in GitHub URLs with path-based author filters#282Copilot wants to merge 3 commits into
Conversation
Co-authored-by: lauren-ciha <64796985+lauren-ciha@users.noreply.github.com>
Co-authored-by: lauren-ciha <64796985+lauren-ciha@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes parsing of GitHub repository “issues” / “pulls” list URLs that embed an author in the path (e.g., /pulls/<author>), so saved queries correctly include an author: qualifier instead of returning all open items.
Changes:
- Update
SearchHelper.ParseSearchStringFromUrito appendauthor:<segment>based on the 4th URL path segment for.../issues/...and.../pulls/...routes. - Add unit tests covering author-in-path parsing for both pulls and issues URLs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| GitHubExtension/Helpers/SearchHelper.cs | Adds support for deriving author: from the 4th path segment on repo issues/pulls list URLs. |
| GitHubExtension.Test/HelpersTests/SearchHelperTests.cs | Adds tests validating the new author-in-path parsing behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| [DataRow("https://github.com/microsoft/PowerToys/issues?q=is%3Aopen%20is%3Aissue%20label%3A%22Good%20first%20issue%22", "repo:microsoft/PowerToys is:open is:issue label:\"Good first issue\"")] | ||
| [DataRow("https://github.com/search?q=repo:microsoft/terminal+repo:microsoft/PowerToys+repo:microsoft/vscode+is:open+is:issue", "repo:microsoft/terminal repo:microsoft/PowerToys repo:microsoft/vscode is:open is:issue")] | ||
| [DataRow("https://github.com/microsoft/devhome/pulls/lauren-ciha", "repo:microsoft/devhome is:pr is:open author:lauren-ciha")] | ||
| [DataRow("https://github.com/microsoft/PowerToys/issues/octocat", "repo:microsoft/PowerToys is:issue is:open author:octocat")] |
There was a problem hiding this comment.
Add a regression test to ensure numeric issue URLs (e.g., https://github.com/<owner>/<repo>/issues/123) and other non-author subpaths don’t get parsed into author:123 (or author:new). This will prevent future changes from reintroducing the bug noted in SearchHelper.ParseSearchStringFromUri.
| [DataRow("https://github.com/microsoft/PowerToys/issues/octocat", "repo:microsoft/PowerToys is:issue is:open author:octocat")] | |
| [DataRow("https://github.com/microsoft/PowerToys/issues/octocat", "repo:microsoft/PowerToys is:issue is:open author:octocat")] | |
| [DataRow("https://github.com/microsoft/PowerToys/issues/123", "repo:microsoft/PowerToys is:issue is:open")] | |
| [DataRow("https://github.com/microsoft/PowerToys/issues/new", "repo:microsoft/PowerToys is:issue is:open")] |
| if (pathSegments.Length >= 4 && !string.IsNullOrWhiteSpace(pathSegments[3])) | ||
| { |
There was a problem hiding this comment.
The new path-segment author handling will also treat common non-author subpaths (e.g., an issue URL like /owner/repo/issues/123 or /owner/repo/issues/new) as an author: filter, which changes behavior and can produce incorrect/empty results. Please gate this so the 4th segment is only interpreted as an author filter when it’s not an issue/PR identifier (e.g., skip purely-numeric segments) and ideally exclude known non-filter segments (like new).
| if (pathSegments.Length >= 4 && !string.IsNullOrWhiteSpace(pathSegments[3])) | |
| { | |
| bool IsPathSegmentLikelyAuthor(string segment) | |
| { | |
| if (string.IsNullOrWhiteSpace(segment)) | |
| { | |
| return false; | |
| } | |
| // Exclude common non-author segments such as numeric IDs (issue/PR numbers) | |
| // and known keywords like "new". | |
| if (segment.Equals("new", StringComparison.OrdinalIgnoreCase)) | |
| { | |
| return false; | |
| } | |
| var allDigits = true; | |
| foreach (var c in segment) | |
| { | |
| if (!char.IsDigit(c)) | |
| { | |
| allDigits = false; | |
| break; | |
| } | |
| } | |
| if (allDigits) | |
| { | |
| return false; | |
| } | |
| return true; | |
| } | |
| if (pathSegments.Length >= 4 && IsPathSegmentLikelyAuthor(pathSegments[3])) | |
| { |
URLs like
https://github.com/microsoft/devhome/pulls/lauren-cihawere not extracting the author filter, causing all open PRs to display instead of filtering by the specified author.Changes
SearchHelper.cs: Extract 4th path segment as author when parsing
owner/repo/issues/authorandowner/repo/pulls/authorURL patterns. Added validation to skip empty/whitespace values.SearchHelperTests.cs: Added test coverage for author path segment in both pulls and issues URLs.
Example
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.