pathutil

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDirectoryOfFile

func GetDirectoryOfFile(path string) string

GetDirectoryOfFile returns the directory containing the given file path

func ValidatePathWithinBase

func ValidatePathWithinBase(targetPath string, baseDir string) error

ValidatePathWithinBase checks if targetPath is within baseDir (no path traversal escape) This is optional validation for security-sensitive operations Pass empty baseDir to skip validation

Types

type PathExpander

type PathExpander struct {
	// contains filtered or unexported fields
}

PathExpander provides path expansion functionality

func NewPathExpander

func NewPathExpander(renderer template.Renderer) *PathExpander

NewPathExpander creates a new PathExpander with the given template renderer

func (*PathExpander) ExpandPath

func (p *PathExpander) ExpandPath(originalPath string, currentDir string, context map[string]interface{}) (string, error)

ExpandPath expands a path with template variables and special prefixes (~, ., ./)

func (*PathExpander) SafeExpandPath

func (p *PathExpander) SafeExpandPath(originalPath string, currentDir string, context map[string]interface{}, baseDir string) (string, error)

SafeExpandPath is like ExpandPath but validates the result is within baseDir Pass empty baseDir to disable validation (same as ExpandPath)

Jump to

Keyboard shortcuts

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