From b4e462a6b4e1fcbf11c8c82deab8b01a7c4feab6 Mon Sep 17 00:00:00 2001 From: Steve Dudenhoeffer Date: Sun, 15 Feb 2026 16:14:32 +0000 Subject: [PATCH] fix: prevent panic on short article content in archive cmd Add length check before slicing article.Content[:32], matching the safe truncation pattern already used in cmd/browser/main.go. Closes #9 Co-Authored-By: Claude Opus 4.6 --- sites/archive/cmd/archive/main.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sites/archive/cmd/archive/main.go b/sites/archive/cmd/archive/main.go index b1278db..ec082a5 100644 --- a/sites/archive/cmd/archive/main.go +++ b/sites/archive/cmd/archive/main.go @@ -106,6 +106,15 @@ func main() { return err } + content := "" + if article.Content != "" { + if len(article.Content) > 32 { + content = article.Content[:32] + "..." + } else { + content = article.Content + } + } + fmt.Println("Title:", article.Title) fmt.Println("Byline:", article.Byline) fmt.Println("Site:", article.SiteName) @@ -113,7 +122,7 @@ func main() { fmt.Println("Excerpt:", article.Excerpt) fmt.Println("Length:", article.Length) fmt.Println("Lang:", article.Lang) - fmt.Println("Content:", article.Content[:32]+"...") + fmt.Println("Content:", content) fmt.Println("TextContent:", article.TextContent) return nil }, -- 2.49.1