From c0a2648436c8f232f0b550130bc1dff53682cc4a Mon Sep 17 00:00:00 2001 From: Kynan Ware <47394200+BagToad@users.noreply.github.com> Date: Tue, 16 Sep 2025 17:34:57 -0600 Subject: [PATCH] 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. --- pkg/cmd/agent-task/shared/log.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/cmd/agent-task/shared/log.go b/pkg/cmd/agent-task/shared/log.go index a1b1740e0..28b98eea7 100644 --- a/pkg/cmd/agent-task/shared/log.go +++ b/pkg/cmd/agent-task/shared/log.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "io" + "path/filepath" "slices" "strings" @@ -366,10 +367,9 @@ func stripDiffFormat(diff string) string { // renderFileContentAsMarkdown renders the given content as markdown // based on the file extension of the path. func renderFileContentAsMarkdown(path, content string, w io.Writer, io *iostreams.IOStreams) error { - parts := strings.Split(path, ".") - lang := parts[len(parts)-1] + lang := filepath.Ext(filepath.ToSlash(path)) - if lang == "md" { + if lang == ".md" { return renderRawMarkdown(content, w, io) }