url

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2022 License: LGPL-2.1 Imports: 9 Imported by: 0

Documentation

Overview

Commands for processing and working with URLs.

Index

Constants

This section is empty.

Variables

View Source
var DefaultUrlScheme = executil.Env(`FRIENDSCRIPT_URL_DEFAULT_SCHEME`, `https`)

if unspecified, default to HTTPS. This is probably in violation of some RFC, but in 2020 I'd rather default to encryption over none. If the scheme is important to the user, they should specify it. This is also exposed as a package-level variable that implementers may change directly or via environment variable

Functions

This section is empty.

Types

type Commands

type Commands struct {
	utils.Module
	// contains filtered or unexported fields
}

func New

func New(env utils.Runtime) *Commands

func (*Commands) EncodeQuery

func (self *Commands) EncodeQuery(querymap interface{}) (string, error)

Take a map or previous URL response structure and encode the values into a string that can be used in another URL or form post data. This command does not automaticlly prepend a "?" character to the output.

func (*Commands) Escape

func (self *Commands) Escape(stringOrStruct interface{}) (string, error)

Escapes the string so it can be safely placed inside a URL path segment, replacing special characters (including /) with %XX sequences as needed.

func (*Commands) Parse

func (self *Commands) Parse(u interface{}) (*URL, error)

Parse the given URL string or structure, and return a structured representation of the various parts of a URL.

func (*Commands) ParseQuery

func (self *Commands) ParseQuery(urlOrQueryString interface{}) (map[string]interface{}, error)

Take a URL or map of query string key=value pairs and return a map of values.

func (*Commands) Unescape

func (self *Commands) Unescape(stringOrStruct interface{}) (string, error)

type URL

type URL struct {
	Scheme   string                 `json:"scheme"`
	Host     string                 `json:"host"`
	Domain   string                 `json:"domain"`
	Port     int                    `json:"port"`
	Path     string                 `json:"path"`
	RawQuery string                 `json:"rawquery"`
	Fragment string                 `json:"fragment"`
	Query    map[string]interface{} `json:"query"`
	Full     string                 `json:"full"`
	// contains filtered or unexported fields
}

func (*URL) String

func (self *URL) String() string

Jump to

Keyboard shortcuts

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