|
|
@@ -68,6 +68,34 @@ func TestIsAbsoluteURL(t *testing.T) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+func TestIsValidProxyURL(t *testing.T) {
|
|
|
+ scenarios := map[string]bool{
|
|
|
+ "http://127.0.0.1:3128": true,
|
|
|
+ "http://[::1]:1055": true,
|
|
|
+ "https://proxy.example.org": true,
|
|
|
+ "socks5://127.0.0.1:1080": true,
|
|
|
+ "socks5h://127.0.0.1:1080": true,
|
|
|
+ "socks5://[::1]:1055": true,
|
|
|
+ "socks5h://[::1]:1055": true,
|
|
|
+ "socks5://[::1%25eno1]:1055": true,
|
|
|
+ "ftp://host": false,
|
|
|
+ "/relative/path": false,
|
|
|
+ "invalid url": false,
|
|
|
+ "http://[::1": false,
|
|
|
+ "http:///var/run/socket": false,
|
|
|
+ "sock:///socket.file": false,
|
|
|
+ "socks5://[::1%eno1]:1055": false,
|
|
|
+ "": false,
|
|
|
+ }
|
|
|
+
|
|
|
+ for input, expected := range scenarios {
|
|
|
+ actual := IsValidProxyURL(input)
|
|
|
+ if actual != expected {
|
|
|
+ t.Errorf(`Unexpected result, got %v instead of %v for %q`, actual, expected, input)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
func TestAbsoluteURL(t *testing.T) {
|
|
|
type absoluteScenario struct {
|
|
|
name string
|