url

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AbsoluteURL

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

func AbsoluteURLFromGo

func AbsoluteURLFromGo(url *gurl.URL) (AbsoluteURL, error)

Create a AbsoluteURL from a Go net/url URL.

func AbsoluteURLFromString

func AbsoluteURLFromString(url string) (AbsoluteURL, error)

Creates a AbsoluteURL from its encoded string representation.

func (AbsoluteURL) Equivalent

func (u AbsoluteURL) Equivalent(url URL) bool

Equivalent implements URL

func (AbsoluteURL) Extension

func (u AbsoluteURL) Extension() string

Extension implements URL

func (AbsoluteURL) Filename

func (u AbsoluteURL) Filename() string

Filename implements URL

func (AbsoluteURL) Fragment

func (u AbsoluteURL) Fragment() string

Fragment implements URL

func (AbsoluteURL) IsFile

func (u AbsoluteURL) IsFile() bool

Indicates whether this URL points to a file.

func (AbsoluteURL) IsHTTP

func (u AbsoluteURL) IsHTTP() bool

Indicates whether this URL points to a HTTP resource.

func (AbsoluteURL) Normalize

func (u AbsoluteURL) Normalize() URL

Normalize implements URL

func (AbsoluteURL) Path

func (u AbsoluteURL) Path() string

Path implements URL

func (AbsoluteURL) Raw

func (u AbsoluteURL) Raw() *gurl.URL

Raw implements URL

func (AbsoluteURL) Relativize

func (u AbsoluteURL) Relativize(url URL) URL

Relativize implements URL Note that unlike other functions, this can return nil! Logic copied from Java: https://github.com/openjdk/jdk/blob/de90204b60c408ef258a2d2515ad252de4b23536/src/java.base/share/classes/java/net/URI.java#L2269

func (AbsoluteURL) RemoveFragment

func (u AbsoluteURL) RemoveFragment() URL

RemoveFragment implements URL

func (AbsoluteURL) RemoveQuery

func (u AbsoluteURL) RemoveQuery() URL

RemoveQuery implements URL

func (AbsoluteURL) Resolve

func (u AbsoluteURL) Resolve(url URL) URL

Resolve implements URL

func (AbsoluteURL) Scheme

func (u AbsoluteURL) Scheme() Scheme

Identifies the type of URL.

func (AbsoluteURL) String

func (u AbsoluteURL) String() string

String implements URL

func (AbsoluteURL) ToFilepath

func (u AbsoluteURL) ToFilepath() string

Converts the URL to a filepath, if it's a file URL.

type RelativeURL

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

Represents a relative Uniform Resource Locator. RelativeURL implements URL

func RelativeURLFromGo

func RelativeURLFromGo(url *gurl.URL) (RelativeURL, error)

Create a RelativeURL from a Go net/url URL.

func RelativeURLFromString

func RelativeURLFromString(url string) (RelativeURL, error)

Creates a RelativeURL from its encoded string representation.

func URLFromDecodedPath

func URLFromDecodedPath(path string) (RelativeURL, error)

Creates a RelativeURL from a percent-decoded path.

func (RelativeURL) Equivalent

func (u RelativeURL) Equivalent(url URL) bool

Equivalent implements URL

func (RelativeURL) Extension

func (u RelativeURL) Extension() string

Extension implements URL

func (RelativeURL) Filename

func (u RelativeURL) Filename() string

Filename implements URL

func (RelativeURL) Fragment

func (u RelativeURL) Fragment() string

Fragment implements URL

func (RelativeURL) Normalize

func (u RelativeURL) Normalize() URL

Normalize implements URL

func (RelativeURL) Path

func (u RelativeURL) Path() string

func (RelativeURL) Raw

func (u RelativeURL) Raw() *gurl.URL

Raw implements URL

func (RelativeURL) Relativize

func (u RelativeURL) Relativize(url URL) URL

Relativize implements URL Note that unlike other functions, this can return nil! Logic copied from Java: https://github.com/openjdk/jdk/blob/de90204b60c408ef258a2d2515ad252de4b23536/src/java.base/share/classes/java/net/URI.java#L2269

func (RelativeURL) RemoveFragment

func (u RelativeURL) RemoveFragment() URL

RemoveFragment implements URL

func (RelativeURL) RemoveQuery

func (u RelativeURL) RemoveQuery() URL

RemoveQuery implements URL

func (RelativeURL) Resolve

func (u RelativeURL) Resolve(url URL) URL

Resolve implements URL

func (RelativeURL) String

func (u RelativeURL) String() string

String implements URL

type Scheme

type Scheme string
const (
	SchemeHTTP  Scheme = "http"
	SchemeHTTPS Scheme = "https"
	SchemeData  Scheme = "data"
	SchemeFTP   Scheme = "ftp"
	SchemeS3    Scheme = "s3" // Amazon S3-compatible
	SchemeGS    Scheme = "gs" // Google Cloud Storage
	SchemeOPDS  Scheme = "opds"
	SchemeFile  Scheme = "file"
)

func SchemeFromString

func SchemeFromString(s string) Scheme

func (Scheme) IsCloud

func (s Scheme) IsCloud() bool

func (Scheme) IsFile

func (s Scheme) IsFile() bool

func (Scheme) IsHTTP

func (s Scheme) IsHTTP() bool

func (Scheme) String

func (s Scheme) String() string

type URL

type URL interface {
	Path() string            // Decoded path segments identifying a location.
	Filename() string        // Decoded filename portion of the URL path.
	Extension() string       // Extension of the filename portion of the URL path.
	RemoveQuery() URL        // Returns a copy of this URL after dropping its query.
	Fragment() string        // Returns the decoded fragment present in this URL, if any.
	RemoveFragment() URL     // Returns a copy of this URL after dropping its fragment.
	Resolve(url URL) URL     // Resolves the given [url] to this URL.
	Relativize(url URL) URL  // Relativizes the given [url] against this URL.
	Normalize() URL          // Normalizes the URL using a subset of the RFC-3986 rules (https://datatracker.ietf.org/doc/html/rfc3986#section-6).
	String() string          // Encodes the URL to a string.
	Raw() *gurl.URL          // Returns the underlying Go URL.
	Equivalent(url URL) bool // Returns whether the receiver is equivalent to the given `url` after normalization.
}

A Uniform Resource Locator.

https://url.spec.whatwg.org/

func FromEPUBHref

func FromEPUBHref(href string) (URL, error)

According to the EPUB specification, the HREFs in the EPUB package must be valid URLs (so percent-encoded). Unfortunately, many EPUBs don't follow this rule, and use invalid HREFs such as `my chapter.html` or `/dir/my chapter.html`.

As a workaround, we assume the HREFs are valid percent-encoded URLs, and fallback to decoded paths if we can't parse the URL.

func FromFilepath

func FromFilepath(path string) (URL, error)

func FromLocalFile

func FromLocalFile(file *os.File) (URL, error)

func MustURLFromString

func MustURLFromString(url string) URL

A proxy for URLFromString that panics on error.

func URLFromGo

func URLFromGo(url *gurl.URL) (URL, error)

Create a URL from a Go net/url URL.

func URLFromString

func URLFromString(url string) (URL, error)

Creates a URL from its encoded string representation.

Directories

Path Synopsis
Package uritemplates is a level 3 implementation of RFC 6570 (URI Template, http://tools.ietf.org/html/rfc6570).
Package uritemplates is a level 3 implementation of RFC 6570 (URI Template, http://tools.ietf.org/html/rfc6570).

Jump to

Keyboard shortcuts

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