From e7174866e501dcdd525660cafe788ee2e55ac76b Mon Sep 17 00:00:00 2001 From: wzdnzd Date: Mon, 5 Jun 2023 12:40:46 +0800 Subject: [PATCH] fix: nil pointer in urltest (#603) --- adapter/adapter.go | 2 +- common/utils/ranges.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/adapter/adapter.go b/adapter/adapter.go index d2c362bc..32fd2b77 100644 --- a/adapter/adapter.go +++ b/adapter/adapter.go @@ -287,7 +287,7 @@ func (p *Proxy) URLTest(ctx context.Context, url string, expectedStatus utils.In } } - if !expectedStatus.Check(uint16(resp.StatusCode)) { + if expectedStatus != nil && !expectedStatus.Check(uint16(resp.StatusCode)) { // maybe another value should be returned for differentiation err = errors.New("response status is inconsistent with the expected status") } diff --git a/common/utils/ranges.go b/common/utils/ranges.go index a6293f65..705bbdee 100644 --- a/common/utils/ranges.go +++ b/common/utils/ranges.go @@ -63,7 +63,7 @@ func NewIntRangesFromList[T constraints.Integer](list []string) (IntRanges[T], e } func (ranges IntRanges[T]) Check(status T) bool { - if ranges == nil || len(ranges) == 0 { + if len(ranges) == 0 { return true }