Skip to content

Commit

Permalink
Rename Contains methods (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
raviqqe authored Feb 28, 2024
1 parent 8ac32ae commit 24d983c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion redirect_http_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (c *redirectHttpClient) Get(u *url.URL, header http.Header) (httpResponse,

code := r.StatusCode()

if c.acceptedStatusCodes.isInSet(code) {
if c.acceptedStatusCodes.Contains(code) {
return r, nil
} else if code >= 300 && code <= 399 {
i++
Expand Down
2 changes: 1 addition & 1 deletion status_code_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ func parseStatusCodeRange(s string) (*statusCodeRange, error) {
return &statusCodeRange{cs[0], cs[1]}, nil
}

func (r statusCodeRange) isInRange(code int) bool {
func (r statusCodeRange) Contains(code int) bool {
return code >= r.start && code < r.end
}
12 changes: 6 additions & 6 deletions status_code_range_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ func TestParsingInvalidStatusCode(t *testing.T) {
func TestInRangeOfStatusCode(t *testing.T) {
r := statusCodeRange{200, 300}

assert.False(t, r.isInRange(199))
assert.True(t, r.isInRange(200))
assert.True(t, r.isInRange(201))
assert.False(t, r.Contains(199))
assert.True(t, r.Contains(200))
assert.True(t, r.Contains(201))

assert.True(t, r.isInRange(298))
assert.True(t, r.isInRange(299))
assert.False(t, r.isInRange(300))
assert.True(t, r.Contains(298))
assert.True(t, r.Contains(299))
assert.False(t, r.Contains(300))
}
4 changes: 2 additions & 2 deletions status_code_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ func parseStatusCodeSet(value string) (statusCodeSet, error) {
return rs, nil
}

func (s statusCodeSet) isInSet(code int) bool {
func (s statusCodeSet) Contains(code int) bool {
for r := range s {
if r.isInRange(code) {
if r.Contains(code) {
return true
}
}
Expand Down

0 comments on commit 24d983c

Please sign in to comment.