Skip to content

Commit 3011c08

Browse files
committed
Only replace methodName prefix if would be empty
Some APIs like 'rollup.rollup' are the same as their namespace and if we remove all occurrences of the namespace from the methodName then it'd result in an empty string. If we hit a situation like this only replace the namespace.
1 parent 263c43f commit 3011c08

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

internal/cmd/generate/commands/genstruct/command.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ type API struct {
239239
name := strings.ReplaceAll(e.Name(), "Request", "")
240240
if strings.HasPrefix(strings.ToLower(name), strings.ToLower(n)) {
241241
methodName := strings.ReplaceAll(name, n, "")
242+
// Some methods are equal to the namespace (like 'rollup.rollup')
243+
// and we don't want to have an empty string here.
244+
if len(methodName) == 0 {
245+
methodName = strings.Replace(name, n, "", 1)
246+
}
242247
b.WriteString(fmt.Sprintf("\t%s %s\n", methodName, name))
243248
}
244249
}
@@ -271,6 +276,11 @@ func New(t Transport) *API {
271276
name := strings.ReplaceAll(e.Name(), "Request", "")
272277
if strings.HasPrefix(strings.ToLower(name), strings.ToLower(n)) {
273278
methodName := strings.ReplaceAll(name, n, "")
279+
// Some methods are equal to the namespace (like 'rollup.rollup')
280+
// and we don't want to have an empty string here.
281+
if len(methodName) == 0 {
282+
methodName = strings.Replace(name, n, "", 1)
283+
}
274284
b.WriteString(fmt.Sprintf("\t\t\t%s: new%sFunc(t),\n", methodName, name))
275285
}
276286
}

internal/cmd/generate/commands/gentests/skips.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ var skipFiles = []string{
3131
"ml/evaluate_data_frame.yml", // Floats as map keys
3232

3333
"watcher/stats/10_basic.yml", // Sets "emit_stacktraces" as string ("true"), not bool
34+
35+
"search.highlight/20_fvh.yml", // bad backslash
3436
}
3537

3638
// TODO: Comments into descriptions for `Skip()`

0 commit comments

Comments
 (0)