Remove space after comma
This commit is contained in:
parent
2e2259a0d9
commit
a3e2b12363
@ -1170,6 +1170,6 @@ func RecordBatchRPCForward(ctx context.Context, backendName string, reqs []*RPCR
|
|||||||
}
|
}
|
||||||
|
|
||||||
func stripXFF(xff string) string {
|
func stripXFF(xff string) string {
|
||||||
ipList := strings.Split(xff, ", ")
|
ipList := strings.Split(xff, ",")
|
||||||
return strings.TrimSpace(ipList[0])
|
return strings.TrimSpace(ipList[0])
|
||||||
}
|
}
|
||||||
|
21
proxyd/proxyd/backend_test.go
Normal file
21
proxyd/proxyd/backend_test.go
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package proxyd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestStripXFF(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
in, out string
|
||||||
|
}{
|
||||||
|
{"1.2.3, 4.5.6, 7.8.9", "1.2.3"},
|
||||||
|
{"1.2.3,4.5.6", "1.2.3"},
|
||||||
|
{" 1.2.3 , 4.5.6 ", "1.2.3"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
actual := stripXFF(test.in)
|
||||||
|
assert.Equal(t, test.out, actual)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user