This will panic with a runtime error: slice bounds out of range if article.Content is less than 32 characters long. The browser cmd at cmd/browser/main.go:50-54 handles this correctly with a length check, but the archive cmd doesn't.
Fix
Add a length check similar to cmd/browser/main.go:
**Parent:** #1
## Description
In `sites/archive/cmd/archive/main.go:116`:
```go
fmt.Println("Content:", article.Content[:32]+"...")
```
This will panic with a `runtime error: slice bounds out of range` if `article.Content` is less than 32 characters long. The browser cmd at `cmd/browser/main.go:50-54` handles this correctly with a length check, but the archive cmd doesn't.
## Fix
Add a length check similar to `cmd/browser/main.go`:
```go
content := article.Content
if len(content) > 32 {
content = content[:32] + "..."
}
fmt.Println("Content:", content)
```
Starting work on this. Will add a length check before slicing article.Content[:32] in sites/archive/cmd/archive/main.go:116, following the same pattern used in cmd/browser/main.go.
Starting work on this. Will add a length check before slicing `article.Content[:32]` in `sites/archive/cmd/archive/main.go:116`, following the same pattern used in `cmd/browser/main.go`.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Parent: #1
Description
In
sites/archive/cmd/archive/main.go:116:This will panic with a
runtime error: slice bounds out of rangeifarticle.Contentis less than 32 characters long. The browser cmd atcmd/browser/main.go:50-54handles this correctly with a length check, but the archive cmd doesn't.Fix
Add a length check similar to
cmd/browser/main.go:Starting work on this. Will add a length check before slicing
article.Content[:32]insites/archive/cmd/archive/main.go:116, following the same pattern used incmd/browser/main.go.Work finished. PR: #34
Added length check before slicing
article.Content[:32], using the same safe truncation pattern fromcmd/browser/main.go.