Skip to content

Commit 00361c6

Browse files
committed
ensure Number is 1 or more
1 parent 2c0ea60 commit 00361c6

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

nearest.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ type NearestRequest struct {
77
Profile string
88
GeoPath GeoPath
99
Bearings []Bearing
10-
11-
Number int
10+
Number int
1211
}
1312

1413
// NearestResponse represents a response from the nearest method
@@ -32,7 +31,9 @@ type nearestResponseOrError struct {
3231

3332
func (r NearestRequest) request() *request {
3433
opts := options{}
35-
opts.addInt("number", r.Number)
34+
if r.Number >= 1 {
35+
opts.addInt("number", r.Number)
36+
}
3637

3738
if len(r.Bearings) > 0 {
3839
opts.set("bearings", bearings(r.Bearings))

nearest_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,14 @@ func TestNearestRequestOverviewOption(t *testing.T) {
1717
t,
1818
"bearings=60%2C380&number=2",
1919
req.request().options.encode())
20+
21+
req = NearestRequest{
22+
Bearings: []Bearing{
23+
{60, 380},
24+
},
25+
}
26+
assert.Equal(
27+
t,
28+
"bearings=60%2C380",
29+
req.request().options.encode())
2030
}

0 commit comments

Comments
 (0)