-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[INS-280] Fix Github "repostories" filter does not respect GHES endpoint #4677
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
db533fb
20bacb7
a24545f
054522a
698fafd
a72f96d
2a9853f
44b2d18
a9c9373
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 |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ import ( | |
| "fmt" | ||
| "io" | ||
| "net/http" | ||
| "net/url" | ||
| "regexp" | ||
| "strings" | ||
| "sync" | ||
|
|
@@ -365,8 +366,30 @@ func (s *Source) normalizeRepo(repo string) (string, error) { | |
| // If it's a repository name (contains / but not http), convert to full URL first | ||
| if strings.Contains(repo, "/") && !regexp.MustCompile(`^[a-z]+://`).MatchString(repo) { | ||
| fullURL := "https://github.com/" + repo | ||
| // If using GitHub Enterprise, adjust the URL accordingly | ||
| if s.conn != nil && s.conn.Endpoint != "" { | ||
| u, err := url.Parse(s.conn.Endpoint) | ||
| if err != nil { | ||
| return "", fmt.Errorf("invalid enterprise endpoint: %w", err) | ||
| } | ||
| // we want to remove any path components from the endpoint and just use the host | ||
| u.Path = "/" + repo | ||
| fullURL = u.String() | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Enterprise check uses wrong condition for standard GitHubHigh Severity The
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this related to this? |
||
| return giturl.NormalizeGithubRepo(fullURL) | ||
| } | ||
|
|
||
| return "", fmt.Errorf("no repositories found for %s", repo) | ||
| } | ||
|
|
||
| // extractRepoNameFromUrl extracts the "owner/repo" name from a GitHub repository URL. | ||
| // Example: http://github.com/owner/repo.git -> owner/repo | ||
| // If an invalid URL is provided, it returns the original string. | ||
| func extractRepoNameFromUrl(repoURL string) string { | ||
| u, err := url.Parse(repoURL) | ||
| if err != nil { | ||
| return repoURL | ||
| } | ||
| cleanedPath := strings.Trim(u.Path, "/") | ||
| return strings.TrimSuffix(cleanedPath, ".git") | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.