Skip to content

Commit

Permalink
do not check host is github.com since GHE should be supported
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Jan 20, 2024
1 parent 3f05410 commit 5ef01fe
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
8 changes: 2 additions & 6 deletions github.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,8 @@ func (gh *GitHub) Releases() ([]*github.RepositoryRelease, error) {
}
}

// GitHubFromURL creates GitHub instance from given repository URL
func GitHubFromURL(u *url.URL) (*GitHub, error) {
if u.Host != "github.com" {
return nil, fmt.Errorf("only 'github.com' is supported but got '%s'", u.String())
}

// NewGitHub creates GitHub instance from given repository URL
func NewGitHub(u *url.URL) (*GitHub, error) {
// '/owner/name'
path := strings.TrimSuffix(u.Path, ".git")
slug := strings.Split(path, "/")
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func main() {
fail(err)
}

gh, err := GitHubFromURL(url)
gh, err := NewGitHub(url)
if err != nil {
fail(err)
}
Expand Down
5 changes: 0 additions & 5 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,6 @@ func TestInvalidRemoteURL(t *testing.T) {
input: "file:///path/to/file.txt",
want: `unsupported protocol scheme "file"`,
},
{
what: "not a GitHub URL",
input: "https://example.com",
want: "only 'github.com' is supported but got 'https://example.com'",
},
{
what: "repository does not exist",
input: "https://github.com/rhysd/this-repository-does-not-exist-oops",
Expand Down

0 comments on commit 5ef01fe

Please sign in to comment.