Skip to content

Commit 0944fa2

Browse files
Merge pull request #22 from phucnguyen1707/fix-over-single-article
Fix single article NNTP overview ranges
1 parent 336ff00 commit 0944fa2

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

internal/news/nntpd/range_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package nntpd
2+
3+
import "testing"
4+
5+
func TestParseRangeSingleArticle(t *testing.T) {
6+
low, high := parseRange("5")
7+
if low != 5 || high != 5 {
8+
t.Fatalf(`parseRange("5") = %d, %d; want 5, 5`, low, high)
9+
}
10+
}

internal/news/nntpd/server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,9 @@ func parseRange(spec string) (low, high int64) {
170170
h, err := strconv.ParseInt(parts[0], 10, 64)
171171
if err != nil {
172172
h = math.MaxInt64
173+
return 0, h
173174
}
174-
return 0, h
175+
return h, h
175176
}
176177
l, _ := strconv.ParseInt(parts[0], 10, 64)
177178
h, err := strconv.ParseInt(parts[1], 10, 64)

0 commit comments

Comments
 (0)