Merge pull request #22 from phucnguyen1707/fix-over-single-article

Fix single article NNTP overview ranges
This commit is contained in:
phucnguyen1707 2026-06-15 10:24:50 +07:00 committed by GitHub
parent 336ff00fa3
commit 0944fa2cb4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View file

@ -0,0 +1,10 @@
package nntpd
import "testing"
func TestParseRangeSingleArticle(t *testing.T) {
low, high := parseRange("5")
if low != 5 || high != 5 {
t.Fatalf(`parseRange("5") = %d, %d; want 5, 5`, low, high)
}
}

View file

@ -170,8 +170,9 @@ func parseRange(spec string) (low, high int64) {
h, err := strconv.ParseInt(parts[0], 10, 64) h, err := strconv.ParseInt(parts[0], 10, 64)
if err != nil { if err != nil {
h = math.MaxInt64 h = math.MaxInt64
return 0, h
} }
return 0, h return h, h
} }
l, _ := strconv.ParseInt(parts[0], 10, 64) l, _ := strconv.ParseInt(parts[0], 10, 64)
h, err := strconv.ParseInt(parts[1], 10, 64) h, err := strconv.ParseInt(parts[1], 10, 64)