pathutil

package
v0.142.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureLeadingSlash

func EnsureLeadingSlash(path string) string

EnsureLeadingSlash normalizes whitespace and ensures the path starts with '/'.

func IsAbsoluteURL

func IsAbsoluteURL(path string) bool

IsAbsoluteURL reports whether the path is an absolute or scheme-relative URL.

func JoinBasePath

func JoinBasePath(basePath, routePath string) string

JoinBasePath joins a normalized base path and route path without duplicating slashes.

func JoinResolvedPath added in v0.113.1

func JoinResolvedPath(basePath, suffix string) string

JoinResolvedPath appends a relative suffix to an already-resolved path or URL.

func NormalizeBasePath

func NormalizeBasePath(basePath string) string

NormalizeBasePath trims and normalizes a base path into /segment form.

func NormalizeLocalPath

func NormalizeLocalPath(path string) (string, error)

NormalizeLocalPath trims and cleans a local file path.

func OpenFileWithinRoot

func OpenFileWithinRoot(root, path string) (*os.File, error)

OpenFileWithinRoot opens a file that must remain inside root.

func PrefixBasePath

func PrefixBasePath(basePath, routePath string) string

PrefixBasePath prefixes a route path with the base path unless already prefixed.

func ReadFileWithinRoot

func ReadFileWithinRoot(root, path string) ([]byte, error)

ReadFileWithinRoot reads a file that must remain inside root.

func ResolveWithinRoot

func ResolveWithinRoot(root, path string) (string, error)

ResolveWithinRoot resolves path under root and rejects escapes.

func TrimTrailingSlash

func TrimTrailingSlash(path string) string

TrimTrailingSlash removes one trailing slash except for the root path.

Types

This section is empty.

Jump to

Keyboard shortcuts

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