-
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 6 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,6 +366,16 @@ 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 | ||
shahzadhaider1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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) | ||
| } | ||
|
|
||
|
|
||
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.
Potential trailing slash bug: if we ever get input like
https://github.com/owner/repo.git/for example, then this will give usrepo.git/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.
➕ I would probably use
strings.TrimRightto remove any trailing slashes and thenpath.Baseto just get the base name.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.
I agree. I didn't touch it because I didn't wanna change existing logic, but I guess yeah, this can be made better