Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions GitHubExtension.Test/HelpersTests/SearchHelperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public void ParseSearchTypeFromSearchString_ValidInput_ReturnsExpectedType(strin
[DataRow("https://github.com/microsoft/PowerToys/issues?q=is%3Aopen%20is%3Aissue%20label%3A%22Product-Command%20Palette%22%20-label%3ARun-Plugin", "repo:microsoft/PowerToys is:open is:issue label:\"Product-Command Palette\" -label:Run-Plugin")]
[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")]

Copilot AI Mar 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
[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")]

Copilot uses AI. Check for mistakes.
[TestMethod]
public void ParseSearchStringFromUri_ValidInput_ReturnsExpectedSearchString(string uriString, string expected)
{
Expand Down
6 changes: 6 additions & 0 deletions GitHubExtension/Helpers/SearchHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ public static IEnumerable<string> GetIsQualifiers(string searchString)
searchBuilder.Add("is:open");
}

// Add author if present (4th path segment)
if (pathSegments.Length >= 4 && !string.IsNullOrWhiteSpace(pathSegments[3]))
{
Comment on lines +123 to +124

Copilot AI Mar 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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]))
{

Copilot uses AI. Check for mistakes.
searchBuilder.Add($"author:{pathSegments[3]}");
}

// Add sort if present
var sortParam = queryParams["sort"];
var orderParam = queryParams["order"];
Expand Down
Loading