Skip to content

Commit

Permalink
Tackle feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jotadrilo committed Apr 14, 2023
1 parent 8048eac commit 7d77599
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion internal/url/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import (
)

var (
isSchemeRegExp = regexp.MustCompile(`^[^:]+://`)
isSchemeRegExp = regexp.MustCompile(`^[^:]+://`)

// Ref: https://github.com/git/git/blob/master/Documentation/urls.txt#L37
scpLikeUrlRegExp = regexp.MustCompile(`^(?:(?P<user>[^@]+)@)?(?P<host>[^:\s]+):(?:(?P<port>[0-9]{1,5}):)?(?P<path>[^\\].*)$`)
)

Expand Down
8 changes: 7 additions & 1 deletion internal/url/url_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ type URLSuite struct{}
var _ = Suite(&URLSuite{})

func (s *URLSuite) TestMatchesScpLike(c *C) {
// See https://github.com/git/git/blob/master/Documentation/urls.txt#L37
examples := []string{
// Most-extended case
"git@github.com:james/bond",
// Most-extended case with port
"git@github.com:22:james/bond",
// Most-extended case with numeric "username"
// Most-extended case with numeric path
"git@github.com:007/bond",
// Most-extended case with port and numeric "username"
"git@github.com:22:007/bond",
Expand All @@ -28,6 +29,11 @@ func (s *URLSuite) TestMatchesScpLike(c *C) {
"git@github.com:22:bond",
// Single repo path with port and numeric repo
"git@github.com:22:007",
// Repo path ending with .git and starting with _
"git@github.com:22:_007.git",
"git@github.com:_007.git",
"git@github.com:_james.git",
"git@github.com:_james/bond.git",
}

for _, url := range examples {
Expand Down

0 comments on commit 7d77599

Please sign in to comment.