Help us shape the future of Go! Take the 2026 Go Developer Survey

nodepath

package
v0.19.13 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package nodepath converts path inputs the way upstream's Node runtime does on the platform orb runs on: url.fileURLToPath, url.pathToFileURL, and the win32 Git Bash/MSYS drive-path rewrite from upstream utils/paths.ts.

Index

Constants

View Source
const AgentDirEnv = "ORB_AGENT_DIR"

AgentDirEnv names the variable that moves Orb's agent directory.

Variables

View Source
var (
	ErrInvalidURL   = errors.New("Invalid URL") //nolint:staticcheck // Node's error text.
	ErrURIMalformed = errors.New("URI malformed")
)

Node's error messages for rejected file URLs (ERR_INVALID_URL, URIError, ERR_INVALID_FILE_URL_PATH); their text is observable, capitals included.

Functions

func AgentDir added in v0.19.1

func AgentDir(configured string) (string, error)

AgentDir is Orb's agent directory: configured, the value of AgentDirEnv, when it is set, else ~/.orb/agent.

func Expand added in v0.19.1

func Expand(path string) (string, error)

Expand resolves a leading ~ against the user's home, when there is one, and converts a file:// URL to its path.

func FileURLToPath

func FileURLToPath(raw string) (string, error)

FileURLToPath parses raw with the WHATWG rules for the file scheme and converts it like Node's url.fileURLToPath: POSIX rejects hosts, win32 maps them to UNC paths and requires a drive letter otherwise.

func HomeDir added in v0.19.1

func HomeDir() (string, error)

HomeDir is the user's home directory, from the account database when $HOME is unset.

func Normalize added in v0.19.1

func Normalize(path string) string

Normalize is upstream's normalizePath: the shell-drive rewrite, then Expand; a malformed file URL stays an ordinary path.

func NormalizeShellPath

func NormalizeShellPath(path string) string

NormalizeShellPath rewrites Git Bash, MSYS, Cygwin and WSL drive paths ("/c/x", "/mnt/c/x", "/cygdrive/c/x") to native drive paths on win32 and returns path unchanged elsewhere.

func NormalizeUnicodeSpaces added in v0.14.0

func NormalizeUnicodeSpaces(value string) string

NormalizeUnicodeSpaces folds pasted path spacing without changing other whitespace.

func PathToFileURL

func PathToFileURL(path string) string

PathToFileURL encodes an absolute native path like Node's url.pathToFileURL.

func Resolve added in v0.19.1

func Resolve(path, base string) string

Resolve normalizes path and makes it absolute against base, like Node's path.resolve(base, path).

Types

This section is empty.

Jump to

Keyboard shortcuts

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