hostutil

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package hostutil provides shared utilities for host URL handling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsLocalhost

func IsLocalhost(host string) bool

IsLocalhost returns true if host is localhost, a .localhost subdomain, 127.0.0.1, or [::1] (with optional port).

func Normalize

func Normalize(host string) string

Normalize converts a host string to a full URL. - Empty string returns empty - localhost/127.0.0.1 defaults to http:// - Other bare hostnames default to https:// - Full URLs are used as-is

func OpenBrowser

func OpenBrowser(url string) error

OpenBrowser opens the specified URL in the default browser.

func RequireSecureURL added in v0.2.0

func RequireSecureURL(rawURL string) error

RequireSecureURL returns an error if the URL uses http:// for a non-localhost host. Localhost (127.0.0.1, ::1, *.localhost) is exempt for local development.

Types

This section is empty.

Jump to

Keyboard shortcuts

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