Skip to content

Commit

Permalink
git: avoid regexp for checking .git suffix
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Chadwell <me@jedevc.com>
  • Loading branch information
jedevc committed Aug 22, 2023
1 parent 50e75e3 commit a8d926a
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions util/gitutil/git_ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package gitutil

import (
"net/url"
"regexp"
"strings"

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

0 comments on commit a8d926a

Please sign in to comment.