Skip to content

Commit 66a586c

Browse files
committed
feedback
1 parent 8114d66 commit 66a586c

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

client/v2/internal/util/util.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ func isSupportedVersion(input string, buildInfo *debug.BuildInfo) bool {
6363
return true // if cannot find the module consider it's supported
6464
}
6565

66+
var sinceCommentRegex = regexp.MustCompile(`\/\/\s*since: (\S+) (\S+)`)
67+
6668
// parseSinceComment parses the `// Since: cosmos-sdk v0.xx` comment on rpc.
6769
func parseSinceComment(input string) (string, string) {
6870
var (
@@ -73,12 +75,11 @@ func parseSinceComment(input string) (string, string) {
7375
input = strings.ToLower(input)
7476
input = strings.ReplaceAll(input, "cosmos sdk", "cosmos-sdk")
7577

76-
re := regexp.MustCompile(`\/\/\s*since: (\S+) (\S+)`)
77-
matches := re.FindStringSubmatch(input)
78+
matches := sinceCommentRegex.FindStringSubmatch(input)
7879
if len(matches) >= 3 {
7980
moduleName, version = matches[1], matches[2]
8081

81-
if !strings.Contains(version, "v") {
82+
if !strings.HasPrefix(version, "v") {
8283
version = "v" + version
8384
}
8485
}

client/v2/internal/util/util_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ func TestParseSinceComment(t *testing.T) {
132132
expectedModuleName: "cosmos-sdk",
133133
expectedVersion: "v0.50.1",
134134
},
135+
{
136+
input: "// since: cosmos-sdk 0.47.0-veronica",
137+
expectedModuleName: "cosmos-sdk",
138+
expectedVersion: "v0.47.0-veronica",
139+
},
135140
{
136141
input: "// Since: x/feegrant v0.1.0",
137142
expectedModuleName: "x/feegrant",

0 commit comments

Comments
 (0)