openBrowser opens the specified URL in the user's default browser.
(url string)
| 117 | |
| 118 | // openBrowser opens the specified URL in the user's default browser. |
| 119 | func openBrowser(url string) error { |
| 120 | var cmd string |
| 121 | var args []string |
| 122 | |
| 123 | switch runtime.GOOS { |
| 124 | case "windows": |
| 125 | // Use rundll32 with shell32.dll,ShellExec_RunDLL to avoid cmd length limitations |
| 126 | // This method is more reliable for long URLs with query parameters |
| 127 | cmd = "rundll32" |
| 128 | args = []string{"url.dll,FileProtocolHandler", url} |
| 129 | case "darwin": |
| 130 | cmd = "open" |
| 131 | args = []string{url} |
| 132 | default: // "linux", "freebsd", "openbsd", "netbsd" |
| 133 | // Check if xdg-open is available before trying to use it |
| 134 | if _, err := exec.LookPath("xdg-open"); err != nil { |
| 135 | return fmt.Errorf("xdg-open not found: %w", err) |
| 136 | } |
| 137 | cmd = "xdg-open" |
| 138 | args = []string{url} |
| 139 | } |
| 140 | |
| 141 | return exec.Command(cmd, args...).Start() |
| 142 | } |
| 143 | |
| 144 | // createShortenedVNCURL creates a shortened URL that forwards to the actual VNC URL |
| 145 | func createShortenedVNCURL(actualURL string) string { |
no outgoing calls