Skip to content

Commit c0a2648

Browse files
committed
Use filepath.Ext to detect file extension in markdown renderer
Replaces manual string splitting with filepath.Ext for determining the file extension in renderFileContentAsMarkdown. This improves accuracy, especially for files with multiple dots in their names.
1 parent 65b45ad commit c0a2648

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

  • pkg/cmd/agent-task/shared

pkg/cmd/agent-task/shared/log.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"fmt"
77
"io"
8+
"path/filepath"
89
"slices"
910
"strings"
1011

@@ -366,10 +367,9 @@ func stripDiffFormat(diff string) string {
366367
// renderFileContentAsMarkdown renders the given content as markdown
367368
// based on the file extension of the path.
368369
func renderFileContentAsMarkdown(path, content string, w io.Writer, io *iostreams.IOStreams) error {
369-
parts := strings.Split(path, ".")
370-
lang := parts[len(parts)-1]
370+
lang := filepath.Ext(filepath.ToSlash(path))
371371

372-
if lang == "md" {
372+
if lang == ".md" {
373373
return renderRawMarkdown(content, w, io)
374374
}
375375

0 commit comments

Comments
 (0)