Documentation
¶
Index ¶
- Variables
- func ContainsControlChar(s string) bool
- func CreateVirtualPath(scheme, id, name string) string
- func CreateVirtualPathSegments(scheme, id string, segments []string) (string, error)
- func ExtractSchemeID(virtualPath, expectedScheme string) (string, error)
- func IsValidScheme(scheme string) bool
- func ValidSegment(name string) bool
- type SegmentsResult
- type URIComponents
- type VirtualPathResult
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidSegments = errors.New("invalid multi-segment virtual path")
ErrInvalidSegments reports a multi-segment virtual path that is not in its canonical form, or a segment that cannot be part of one.
Functions ¶
func ContainsControlChar ¶
ContainsControlChar checks if a string contains any control characters (0x00-0x1F, 0x7F) Returns true if control characters are found (invalid for URLs)
func CreateVirtualPath ¶
CreateVirtualPath creates a properly encoded virtual path for media Example: "kodi-show", "123", "Some Hot/Cold" -> "kodi-show://123/Some%20Hot%2FCold" Both id and name are URL-encoded to ensure round-trip compatibility with ParseVirtualPathStr Note: Simple alphanumeric IDs like "123" or "monkey1" remain unchanged after encoding
func CreateVirtualPathSegments ¶ added in v2.19.0
CreateVirtualPathSegments builds scheme://id/seg/.../seg, escaping the ID and each segment on its own. The result is the canonical form that ParseVirtualPathSegments accepts.
func ExtractSchemeID ¶
ExtractSchemeID extracts the ID component from a scheme-based virtual path with proper URL decoding. Returns error if the path doesn't match the expected scheme. Example: ExtractSchemeID("steam://123/Game%20Name", "steam") -> "123", nil
func IsValidScheme ¶
IsValidScheme validates that a scheme follows RFC 3986 rules: - Must start with a letter - Can contain letters, digits, '+', '-', '.'
func ValidSegment ¶ added in v2.19.0
ValidSegment reports whether name can be one segment of a multi-segment virtual path: non-empty, not "." or "..", valid UTF-8, bounded, and free of control characters and path separators.
Types ¶
type SegmentsResult ¶ added in v2.19.0
SegmentsResult is a parsed multi-segment virtual path.
func ParseVirtualPathSegments ¶ added in v2.19.0
func ParseVirtualPathSegments(value string) (SegmentsResult, error)
ParseVirtualPathSegments splits a multi-segment virtual path into its scheme, ID and decoded segments. It accepts only the canonical form, so a value that parses is byte-identical to the one CreateVirtualPathSegments would make: two spellings of one media item cannot both be stored.
type URIComponents ¶
URIComponents holds parsed URI components
func ParseURIComponents ¶
func ParseURIComponents(uri string) URIComponents
ParseURIComponents manually parses a URI into its components Note: Does not extract fragments - they remain part of name/query for custom schemes Returns empty result if URI contains control characters or has invalid scheme
type VirtualPathResult ¶
VirtualPathResult holds parsed virtual path components
func ParseVirtualPathStr ¶
func ParseVirtualPathStr(virtualPath string) (VirtualPathResult, error)
ParseVirtualPathStr parses a virtual path and returns its components with string ID Virtual path format: scheme://id/name (e.g., "steam://123/Game%20Name") Maps to URL structure: scheme://host/path where host=id, path=name Uses manual parsing to handle malformed URLs gracefully