nodeurl

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package nodeurl ports the parts of Node's url module that PiG needs to match Pi: the WHATWG host parser for file URLs and url.fileURLToPath.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DomainToUnicode

func DomainToUnicode(host string) string

DomainToUnicode is Node's url.domainToUnicode for a host FileHost returned: an IP address is unchanged, and a domain's IDNA labels become Unicode.

func FileHost

func FileHost(server string) (string, error)

FileHost is the WHATWG host parser's result for a file URL's host: an IPv6 address in brackets, a dotted IPv4 address, or a lowercase ASCII domain, where localhost is empty. The input is percent-decoded first, as the parser does.

func FileURLToPath

func FileURLToPath(raw string, windows bool) (string, error)

FileURLToPath converts raw as Node's url.fileURLToPath(raw, {windows}) does: raw is parsed as a WHATWG URL, and a Windows host names a UNC server in Unicode. It returns the Error Node throws for a URL that does not parse, is not a file URL, encodes a path separator, has a host on POSIX, or on Windows has neither a host nor a drive letter.

Types

type Error

type Error struct {
	Code    string
	Message string
}

Error is an error Node's url.fileURLToPath throws, with its code. URIError comes from decodeURIComponent and has no code.

func (*Error) Error

func (e *Error) Error() string

Jump to

Keyboard shortcuts

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