utils

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CHATTERINO_ENV_PREFIX = "CHATTERINO_API_"
)

Variables

This section is empty.

Functions

func Contains

func Contains(haystack []string, needle string) bool

Contains returns true if the given string array (haystack) contains given string (needle)

func FormatThumbnailURL

func FormatThumbnailURL(baseURL string, r *http.Request, urlString string) string

func IsDomain

func IsDomain(url *url.URL, domain string) bool

IsDomain checks whether `url`s domain matches the given domain exactly (non-case sensitive) The `domain` string must be fully lowercased

func IsDomains

func IsDomains(url *url.URL, domains map[string]struct{}) bool

IsDomains checks whether `url`s domain matches any of the given domains exactly (non-case sensitive) The `domains` map should only contain fully lowercased domains

func IsSubdomainOf

func IsSubdomainOf(url *url.URL, parent string) bool

IsSubdomainOf checks whether `url` is a subdomain of `parent`

func LookupEnv added in v1.0.1

func LookupEnv(envSuffix string) (value string, exists bool)

LookupEnv is a thin wrapper of os.LookupEnv, except it prefixes the given envSuffix with the standard environment variable prefix (i.e. CHATTERINO_API_) Calling LookupEnv("YOUTUBE_API_KEY") would return the value for the environment variable CHATTERINO_API_YOUTUBE_API_KEY

func MarshalNoDur

func MarshalNoDur(i interface{}) ([]byte, time.Duration, error)

func StringPtr

func StringPtr(s string) *string

func TruncateString

func TruncateString(s string, maxLength int) string

TruncateString truncates string down to the maximum length with a unicode triple dot if truncation took place

func UnescapeURLArgument

func UnescapeURLArgument(r *http.Request, key string) (string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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