Documentation
¶
Overview ¶
Package uri implements canonical vscode-uri parsing and formatting for Go.
Index ¶
- Variables
- func Basename(u URI) string
- func Extname(u URI) string
- func FsPathFor(u URI, platform Platform, keepDriveLetterCasing bool) string
- type Change
- type Components
- type Error
- type Platform
- type URI
- func Dirname(u URI) URI
- func File(path string) URI
- func FileFor(platform Platform, path string) URI
- func From(c Components) (URI, error)
- func JoinPath(u URI, segments ...string) (URI, error)
- func MustParse(s string) URI
- func Parse(s string) (URI, error)
- func ParseStrict(s string) (URI, error)
- func ResolvePath(u URI, segments ...string) (URI, error)
- func (u URI) Authority() string
- func (u URI) Components() Components
- func (u URI) Fragment() string
- func (u URI) FsPath() string
- func (u URI) IsFile() bool
- func (u URI) IsZero() bool
- func (u URI) MarshalText() ([]byte, error)
- func (u URI) Path() string
- func (u URI) Query() string
- func (u URI) Scheme() string
- func (u URI) String() string
- func (u URI) StringNoEncoding() string
- func (u *URI) UnmarshalText(text []byte) error
- func (u URI) With(change Change) (URI, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMissingScheme reports that strict URI parsing found no scheme. ErrMissingScheme = errors.New("uri: scheme is missing") // ErrInvalidScheme reports that a URI scheme contains illegal characters. ErrInvalidScheme = errors.New("uri: scheme contains illegal characters") // ErrAuthorityPath reports that an authority URI path is not empty or slash-prefixed. ErrAuthorityPath = errors.New("uri: authority path must be empty or begin with slash") // ErrPathAuthority reports that a URI path without authority starts with two slashes. ErrPathAuthority = errors.New("uri: path without authority cannot begin with two slashes") )
Functions ¶
func FsPathFor ¶ added in v1.0.0
FsPathFor returns the filesystem path for u using vscode-uri uriToFsPath semantics over u's canonical component view.
Because URI values do not retain parse-history-only casing, UNC authorities and drive letters use the canonical casing exposed by Authority and Path.
Types ¶
type Change ¶ added in v1.0.0
Change describes URI component replacements for With.
A nil field keeps the existing component. A non-nil pointer replaces that component; a pointer to the empty string clears it, except Scheme follows vscode-uri non-strict scheme fixing and becomes "file" when empty.
type Components ¶ added in v1.0.0
Components contains decoded URI components.
type Error ¶ added in v1.0.0
Error describes a URI validation failure while preserving a typed cause.
type Platform ¶ added in v1.0.0
type Platform uint8
Platform selects filesystem path behavior for URI.file and uriToFsPath.
type URI ¶
type URI string
URI is an immutable, comparable, canonical vscode-uri-compatible URI string.
Constructor functions store the canonical encoded representation, equivalent to vscode-uri's URI.parse(input).toString() result for representable Go input. Decoded component accessors are derived from that canonical representation, so parse-history-only casing such as uppercase drive letters or authority hosts is intentionally not retained.
func Dirname ¶ added in v1.0.0
Dirname returns a URI with its path replaced by Node path.posix.dirname.
func FileFor ¶ added in v1.0.0
FileFor constructs a file URI for path using platform-specific vscode-uri semantics.
func ParseStrict ¶ added in v1.0.0
ParseStrict parses s with vscode-uri strict semantics.
func ResolvePath ¶ added in v1.0.0
ResolvePath resolves URI path segments using Node path.posix semantics.
func (URI) Authority ¶ added in v1.0.0
Authority returns the decoded canonical URI authority.
Authority host casing follows the canonical URI string and is therefore lowercased, matching URI.parse(input).toString() reparsed by vscode-uri rather than vscode-uri's original parse object.
func (URI) Components ¶ added in v1.0.0
func (u URI) Components() Components
Components returns all decoded URI components.
func (URI) MarshalText ¶ added in v1.0.0
MarshalText returns the canonical URI string as text.
func (URI) Path ¶ added in v1.0.0
Path returns the decoded canonical URI path.
Windows drive-letter casing follows the canonical URI string. For example, parsing file:///C:/x and reparsing the canonical string both expose /c:/x.
func (URI) StringNoEncoding ¶ added in v1.0.0
StringNoEncoding returns a URI string with vscode-uri toString(true) semantics.
func (*URI) UnmarshalText ¶ added in v1.0.0
UnmarshalText parses text as a URI using non-strict vscode-uri semantics.