Skip to content

Commit a8d926a

Browse files
committed
git: avoid regexp for checking .git suffix
Signed-off-by: Justin Chadwell <[email protected]>
1 parent 50e75e3 commit a8d926a

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

util/gitutil/git_ref.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package gitutil
22

33
import (
44
"net/url"
5-
"regexp"
65
"strings"
76

87
"github.com/containerd/containerd/errdefs"
@@ -82,8 +81,7 @@ func ParseGitRef(ref string) (*GitRef, error) {
8281
switch remote.Scheme {
8382
// An HTTP(S) URL is considered to be a valid git ref only when it has the ".git[...]" suffix.
8483
case HTTPProtocol, HTTPSProtocol:
85-
var gitURLPathWithFragmentSuffix = regexp.MustCompile(`\.git(?:#.+)?$`)
86-
if !gitURLPathWithFragmentSuffix.MatchString(ref) {
84+
if !strings.HasSuffix(remote.Path, ".git") {
8785
return nil, errdefs.ErrInvalidArgument
8886
}
8987
}

0 commit comments

Comments
 (0)