urlutil

package
v0.62.5 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: MIT Imports: 11 Imported by: 60

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendValues added in v0.62.0

func AppendValues(v1, v2 url.Values, inclDuplicates bool) url.Values

AppendValues appends one `url.Values` to another `url.Values`.

func CondenseURI added in v0.37.0

func CondenseURI(uri string) string

CondenseURI trims spaces and condenses slashes.

func EndpointString

func EndpointString(path, method string, generic bool) string

func GetPathLeaf

func GetPathLeaf(s string) (string, error)

func GetURLBody

func GetURLBody(absoluteURL string) ([]byte, error)

GetURLBody returns an HTTP response byte array body from a URL.

func GetURLPostBody

func GetURLPostBody(absoluteURL string, bodyType string, reqBody io.Reader) ([]byte, error)

GetURLPostBody returns a HTTP post body as a byte array from a URL, body type and an io.Reader.

func IsHTTP added in v0.37.0

func IsHTTP(uri string, inclHTTP, inclHTTPS bool) bool

func Join

func Join(elem ...string) string

Join returns joining URL paths parts.

func JoinAbsolute

func JoinAbsolute(elem ...string) string

JoinAbsolute performs a path.Join() while preserving two slashes after the scheme.

func MatchGeneric

func MatchGeneric(path1, path2 string) bool

func ModifyPath

func ModifyPath(rawurl, newpath string) (string, error)

func ParseURLTemplate

func ParseURLTemplate(input string) (*url.URL, error)

ParseURLTemplate exists to parse templates with variables that do not meet RFC specifications. For example: https://{customer}.example.com:{port}/v5 "invalid URL escape "%7B"" for `{` within a Hostname or "invalid port ":{port}" after host"

func SlugTextToURL added in v0.37.0

func SlugTextToURL(s string, underscore bool) string

func SlugURLToText added in v0.37.0

func SlugURLToText(s string) string

func SplitPath

func SplitPath(urlPath string, stripLeading, stripTrailing bool) []string

SplitPath splits a URL path string with optional removal of leading and trailing slashes.

func ToSlug

func ToSlug(slug []byte) []byte

ToSlug creates a slug byte array from an input byte array. Slugs have words separated by a hyphen with no punctuation or spaces.

func ToSlugLowerString

func ToSlugLowerString(s string) string

ToSlugLowerString creates a lower-cased slug string

func URIHasScheme added in v0.37.0

func URIHasScheme(uri string) bool

URIHasScheme returns a boolean true or false if the string has a URI scheme.

func URIScheme added in v0.37.0

func URIScheme(uri string) string

URIScheme extracts the URI scheme from a string. It returns an empty string if none is encountered.

func URLAddQuery

func URLAddQuery(inputURL *url.URL, qry url.Values, inclDuplicates bool) *url.URL

func URLStringAddQuery added in v0.62.0

func URLStringAddQuery(inputURL string, qry url.Values, inclDuplicates bool) (*url.URL, error)

func URLValuesEncodeSorted added in v0.37.0

func URLValuesEncodeSorted(v url.Values, priorities []string) string

URLValuesEncodeSorted returns and encoded string with sorting

func VarsToGeneric

func VarsToGeneric(input string) string

Types

type URLMore

type URLMore struct {
	URL                  *url.URL
	URLWoQueryWoFragment string
	URLWoFragment        string
	Port                 int
}

UrlMore provides additional URL parsing and reconstruction capabilties above and beyond URL. Specifically it can parse out the port number and return URLs that strip off the target fragment as well as the query string.

func NewURLMore

func NewURLMore() URLMore

func (*URLMore) Inflate

func (urlMore *URLMore) Inflate()

func (*URLMore) Parse

func (urlMore *URLMore) Parse(rawurl string) error

Parse uses `url.Parse()` to create a URL object. When using an already created URL object, simply set the `Url` property and then call `Inflate`.

type URLValidator

type URLValidator struct {
	RequiredSchemes map[string]int
}

func (*URLValidator) RequiredSchemesSorted

func (uv *URLValidator) RequiredSchemesSorted() []string

func (*URLValidator) RequiredSchemesSortedString

func (uv *URLValidator) RequiredSchemesSortedString() string

func (*URLValidator) SchemesToLower

func (uv *URLValidator) SchemesToLower()

func (*URLValidator) ValidateURL

func (uv *URLValidator) ValidateURL(u *url.URL) (*url.URL, error)

func (*URLValidator) ValidateURLString

func (uv *URLValidator) ValidateURLString(s string) (*url.URL, error)

Jump to

Keyboard shortcuts

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