feat: wire gui instance start and delete confirmation
This commit is contained in:
@@ -50,15 +50,18 @@ func (s LaunchSpec) Normalize() (LaunchSpec, error) {
|
||||
return LaunchSpec{}, fmt.Errorf("%w: user data dir must be absolute", ErrInvalidLaunchSpec)
|
||||
}
|
||||
target := strings.TrimSpace(s.TargetURL)
|
||||
parsed, err := url.Parse(target)
|
||||
if err != nil || parsed.Host == "" || parsed.User != nil || (parsed.Scheme != "http" && parsed.Scheme != "https") {
|
||||
return LaunchSpec{}, fmt.Errorf("%w: target URL must be absolute http or https", ErrInvalidLaunchSpec)
|
||||
if target != "" {
|
||||
parsed, err := url.Parse(target)
|
||||
if err != nil || parsed.Host == "" || parsed.User != nil || (parsed.Scheme != "http" && parsed.Scheme != "https") {
|
||||
return LaunchSpec{}, fmt.Errorf("%w: target URL must be absolute http or https", ErrInvalidLaunchSpec)
|
||||
}
|
||||
target = parsed.String()
|
||||
}
|
||||
normalized := s
|
||||
normalized.Executable = strings.TrimSpace(s.Executable)
|
||||
normalized.UserDataDir = filepath.Clean(userDataDir)
|
||||
normalized.ProfileDirectory = strings.TrimSpace(s.ProfileDirectory)
|
||||
normalized.TargetURL = parsed.String()
|
||||
normalized.TargetURL = target
|
||||
normalized.ProxyServer = strings.TrimSpace(s.ProxyServer)
|
||||
normalized.ExtraArgs = append([]string(nil), s.ExtraArgs...)
|
||||
return normalized, nil
|
||||
|
||||
@@ -42,3 +42,14 @@ func TestLaunchSpecNormalizeRejectsUnsafeValues(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLaunchSpecNormalizeAllowsAnEmptyTargetURL(t *testing.T) {
|
||||
profile := filepath.Join(t.TempDir(), "profile")
|
||||
normalized, err := (LaunchSpec{Kind: BrowserChrome, UserDataDir: profile}).Normalize()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if normalized.TargetURL != "" {
|
||||
t.Fatalf("target URL = %q, want empty", normalized.TargetURL)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user