virtualpath

package
v2.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsControlChar

func ContainsControlChar(s string) bool

ContainsControlChar checks if a string contains any control characters (0x00-0x1F, 0x7F) Returns true if control characters are found (invalid for URLs)

func CreateVirtualPath

func CreateVirtualPath(scheme, id, name string) string

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 ExtractSchemeID

func ExtractSchemeID(virtualPath, expectedScheme string) (string, error)

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

func IsValidScheme(scheme string) bool

IsValidScheme validates that a scheme follows RFC 3986 rules: - Must start with a letter - Can contain letters, digits, '+', '-', '.'

Types

type URIComponents

type URIComponents struct {
	Scheme string
	Rest   string // Everything after ://
	Query  string
}

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

type VirtualPathResult struct {
	Scheme string
	ID     string
	Name   string
}

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

Jump to

Keyboard shortcuts

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