diff --git a/internal/github/parser.go b/internal/github/parser.go index c23abba..7116037 100644 --- a/internal/github/parser.go +++ b/internal/github/parser.go @@ -30,6 +30,7 @@ import ( var patterns = []string{ `^(?Phttps?)://(?P[^/]+)/(?P[^/]+)/(?P[^/]+)(/(?:tree|blob)/(?P[^/]+)(?P/.*)?)?$`, `^(?Phttps?)://(?Praw\.githubusercontent\.com)/(?P[^/]+)/(?P[^/]+)/(?P[^/]+)(?P/.*)$`, + `^(?Pgit)@(?Pgithub\.com):(?P[^/]+)/(?P[^/]+)\.git$`, } // New factory to create a new GitHub instance. diff --git a/internal/github/parser_public_test.go b/internal/github/parser_public_test.go index acde8bc..be80e64 100644 --- a/internal/github/parser_public_test.go +++ b/internal/github/parser_public_test.go @@ -117,12 +117,34 @@ func (suite *GitHubPublicTestSuite) TestParseOk() { href: "https://raw.githubusercontent.com/retr0h/git-url-parse/main/files/file0.json", }, }, + { + input: "https://www.github.com/retr0h/git-url-parse", + want: &url{ + protocol: "https", + resource: "www.github.com", + owner: "retr0h", + repo: "git-url-parse", + path: "", + branch: "", + provider: "github", + href: "https://www.github.com/retr0h/git-url-parse", + }, + }, + { + input: "git@github.com:retr0h/git-url-parse.git", + want: &url{ + protocol: "git", + resource: "github.com", + owner: "retr0h", + repo: "git-url-parse", + path: "", + branch: "", + provider: "github", + href: "git@github.com:retr0h/git-url-parse.git", + }, + }, } - // "git@github.com:retr0h/git-url-parse.git" - // "git@github.com:foobar/retr0h/git-url-parse.git" - // "https://www.github.com/retr0h/git-url-parse" - for _, tc := range tests { var got internal.RepositoryURLManager got, err := suite.rm.Parse(tc.input) @@ -154,6 +176,13 @@ func (suite *GitHubPublicTestSuite) TestParseFails() { input: "bogus://url/", want: fmt.Sprintf("could match url: %s to any pattern", "bogus://url/"), }, + { + input: "git@github.com:foobar/retr0h/git-url-parse.git", + want: fmt.Sprintf( + "could match url: %s to any pattern", + "git@github.com:foobar/retr0h/git-url-parse.git", + ), + }, } for _, tc := range tests {