Skip to content

Commit

Permalink
fix: address goconst linter finding
Browse files Browse the repository at this point in the history
Signed-off-by: nscuro <nscuro@protonmail.com>
  • Loading branch information
nscuro committed Nov 28, 2023
1 parent 438f6e2 commit 064b068
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/sbom/convert/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,16 @@ var (
vcsUrlGoPkgInRegexWithoutUser = regexp.MustCompile(`^gopkg\.in/([^.]+)\..*$`)
)

const vcsHttpsPrefix = "https://"

func resolveVCSURL(modulePath string) string {
switch {
case strings.HasPrefix(modulePath, "github.com/"):
return "https://" + vcsUrlMajorVersionSuffixRegex.ReplaceAllString(modulePath, "")
return vcsHttpsPrefix + vcsUrlMajorVersionSuffixRegex.ReplaceAllString(modulePath, "")
case vcsUrlGoPkgInRegexWithUser.MatchString(modulePath):
return "https://" + vcsUrlGoPkgInRegexWithUser.ReplaceAllString(modulePath, "github.com/$1/$2")
return vcsHttpsPrefix + vcsUrlGoPkgInRegexWithUser.ReplaceAllString(modulePath, "github.com/$1/$2")
case vcsUrlGoPkgInRegexWithoutUser.MatchString(modulePath):
return "https://" + vcsUrlGoPkgInRegexWithoutUser.ReplaceAllString(modulePath, "github.com/go-$1/$1")
return vcsHttpsPrefix + vcsUrlGoPkgInRegexWithoutUser.ReplaceAllString(modulePath, "github.com/go-$1/$1")
}

return ""
Expand Down

0 comments on commit 064b068

Please sign in to comment.