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

nodepath

package
v0.17.4 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 6 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

This section is empty.

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 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 HostPathToPath

func HostPathToPath(host, pathname string) (string, error)

HostPathToPath converts the host and percent-encoded pathname of an already parsed file URL; host must already be "" for localhost.

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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