feat: add proxy labels and default profiles
This commit is contained in:
@@ -104,6 +104,16 @@ func NormalizeProxyServer(value string) (string, error) {
|
||||
return scheme + "://" + net.JoinHostPort(strings.ToLower(parsed.Hostname()), strconv.Itoa(port)), nil
|
||||
}
|
||||
|
||||
// NormalizeProxyName returns a non-empty display name for a locally saved
|
||||
// proxy profile. It deliberately carries no endpoint or credentials semantics.
|
||||
func NormalizeProxyName(value string) (string, error) {
|
||||
name := strings.TrimSpace(value)
|
||||
if name == "" {
|
||||
return "", fmt.Errorf("%w: proxy name is required", ErrInvalidLaunchSpec)
|
||||
}
|
||||
return name, nil
|
||||
}
|
||||
|
||||
func ValidRemoteDebugPort(port int) bool {
|
||||
return port >= MinRemoteDebugPort && port <= MaxRemoteDebugPort
|
||||
}
|
||||
|
||||
@@ -80,3 +80,13 @@ func TestNormalizeProxyServerCanonicalizesAndRejectsCredentials(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeProxyNameRequiresNonEmptyDisplayText(t *testing.T) {
|
||||
got, err := NormalizeProxyName(" 新加坡出口 ")
|
||||
if err != nil || got != "新加坡出口" {
|
||||
t.Fatalf("NormalizeProxyName() = %q, %v", got, err)
|
||||
}
|
||||
if _, err := NormalizeProxyName(" \t "); !errors.Is(err, ErrInvalidLaunchSpec) {
|
||||
t.Fatalf("empty proxy name error = %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user