lib

package
v0.0.0-...-009bde4 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Lib regex
	// NOTE: multi-line mode flag (?m) enables ^ and $ to match line beginnings and endings
	RegComments     = regexp.MustCompile(`(?m)^(//|#)([^\r\n]*(\r?\n|\r))`)
	RegEmptyNewLine = regexp.MustCompile(`(?m)^\r?\n|\r$`)
	RegEnv          = regexp.MustCompile(`{{[ \t\f]*[\w\-]+[ \t\f]*}}`)
	RegHeaders      = regexp.MustCompile(`(?m)^(?P<Fieldname>[\w\-]+):[ \t\f]*(?P<Fieldvalue>[^\r\n]+[ \t\f]*)$`)
	RegInputFileRef = regexp.MustCompile(`(?m)^<[ \t\f]+(?P<Filepath>[^\r\n]+)$`)
	RegIp           = regexp.MustCompile(`\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\[([A-Fa-f\d%]{0,4}:?){0,8}\]`)
	RegLineEnding   = regexp.MustCompile(`\r?\n|\r`)
	// Boundary chars:
	// https://stackoverflow.com/questions/147451/what-are-valid-characters-for-creating-a-multipart-form-boundary
	// Boundary length:
	// https://stackoverflow.com/questions/3508338/what-is-the-boundary-in-multipart-form-data
	RegMultipartFormDataHeader = regexp.
								MustCompile(`(?m)^Content-Type: multipart\/form-data(; boundary=(?P<Boundary>[0-9a-zA-Z'()+_,\-.\/:=?]{1,70}))?$(\r?\n|\r)`)
	// Non Ascii regex source: https://stackoverflow.com/questions/2124010/grep-regex-to-match-non-ascii-characters
	RegNonAscii    = regexp.MustCompile(`[^\x00-\x7F]`)
	RegRequestLine = regexp.
					MustCompile(`(?m)^((GET|HEAD|POST|PUT|DELETE|CONNECT|PATCH|OPTIONS|TRACE)[ \t\f]+)?(([\d/\[*]|http|https)\S*)((\r?\n|\r)^\s+[\w\-\/?#~:.%+]+(\r?\n|\r)?)*([ \t\f]+(HTTP/\d+(\.\d+)?))?$(\r?\n|\r)`)
	RegRequestLineQuery       = regexp.MustCompile(`(?m)\?[^\s?]+$`)
	RegRequestLineFragment    = regexp.MustCompile(`(?m)#[^\s#]+$`)
	RegRequestLinePathSegment = regexp.MustCompile(`(?m)\/[^\/][^\s.]+$`)
	RegResponseHandler        = regexp.
								MustCompile(`(?m)^>[ \t\f]+([^\r\n]*(\r?\n|\r)$|{%(.|(\r?\n|\r))+%})$(\r?\n|\r)`)
	RegResponseRef = regexp.MustCompile(`(?m)^<>[ \t\f]+[^\r\n]*$(\r?\n|\r)`)
	RegSeparator   = regexp.MustCompile(`(?m)^###[^\r\n]*(\r?\n|\r)`)
	RegUrlScheme   = regexp.MustCompile(`(?m)^(http|https)://`)
)

Functions

func ConvertToAbsolutePath

func ConvertToAbsolutePath(p string) (string, error)

Converts any file name or relative path to absolute path using context' pathPrefix

func GetTerminalSize

func GetTerminalSize() (width int, height int, err error)

Returns the current dimensions of file descriptor (os.Stdout.Fd()) (no scrollback buffer)

func IsUrlValid

func IsUrlValid(s string) bool

func TrimEmptyStringsFromSlice

func TrimEmptyStringsFromSlice(s []string) []string

func TrimLeftEmptyStringsFromSlice

func TrimLeftEmptyStringsFromSlice(s []string) []string

func TrimRightEmptyStringsFromSlice

func TrimRightEmptyStringsFromSlice(s []string) []string

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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