Documentation
¶
Overview ¶
Package browser provides utilities for opening URLs in the system's default browser. This package can be used by applications that need to detect browser availability or open URLs as part of authentication flows or other user interactions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanOpen ¶
func CanOpen() bool
CanOpen checks if we can open a browser in the current environment. Returns true if the required browser command exists for the current operating system. This is useful for determining whether to attempt automatic browser opening or to fall back to displaying instructions to the user.
func Open ¶
Open attempts to open a URL in the system's default browser. Returns an error if the URL is invalid, the platform is unsupported, or the browser command fails to execute.
The URL is validated before opening to ensure it uses http or https scheme and does not contain embedded credentials or control characters.
Security considerations:
- Only http and https URL schemes are allowed
- URLs are validated and sanitized before execution
- Commands are executed with proper argument separation to prevent injection
- The browser process runs independently and does not block the caller
Types ¶
This section is empty.