-
Notifications
You must be signed in to change notification settings - Fork 10
Fix author parsing in GitHub URLs with path-based author filters #282
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
base: main
Are you sure you want to change the base?
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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])) | |
| { |
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.
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 intoauthor:123(orauthor:new). This will prevent future changes from reintroducing the bug noted in SearchHelper.ParseSearchStringFromUri.