chore: sync local updates
This commit is contained in:
24
mengyaping-backend/utils/intranet_test.go
Normal file
24
mengyaping-backend/utils/intranet_test.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package utils
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestIsIntranetURL(t *testing.T) {
|
||||
cases := []struct {
|
||||
raw string
|
||||
want bool
|
||||
}{
|
||||
{"http://10.0.0.233:8080/path", true},
|
||||
{"https://192.168.1.1/", true},
|
||||
{"http://127.0.0.1:3000", true},
|
||||
{"http://[fd00::1]/", true},
|
||||
{"https://1.1.1.1/", false},
|
||||
{"https://example.com/", false},
|
||||
{"http://nas.local:8080", false},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
got := IsIntranetURL(tc.raw)
|
||||
if got != tc.want {
|
||||
t.Fatalf("%q: got %v want %v", tc.raw, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user