browser

package
v1.30.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package browser opens a URL in the user's default web browser.

The URL reaching Open comes from a config profile or from an API response, neither of which this CLI authored, so Validate is not a formality: a platform opener hands its argument to the OS handler registry, where a non-http scheme selects a program rather than a browser. macOS `open` will launch an application for a custom scheme, and on Windows `cmd /c start` treats its argument as a shell token. So every Open validates first, and callers that only print the URL validate too — the same value is wrong in both directions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(rawURL, browserEnv string) (string, error)

Open launches rawURL in the default browser. It validates first and returns the validated URL so a caller can report exactly what was opened.

func Validate

func Validate(raw string) (string, error)

Validate returns raw trimmed of a trailing slash, once it is an absolute http or https URL with a host. Anything else is an error naming what arrived, because the usual cause is a profile holding a host with no scheme and the remedy is to fix the profile.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL