Documentation ¶
Index ¶
- Constants
- Variables
- func AutoMergeRelPaths(path1 string, path2 string) (string, error)
- func ParamEncode(data string) string
- func PercentEncoding(data string) string
- func URLEncodeWithEscapes(data string, charset ...rune) string
- type OrderedParams
- func (o *OrderedParams) Add(key string, value ...string)
- func (o *OrderedParams) Clone() *OrderedParams
- func (o *OrderedParams) Decode(raw string)
- func (o *OrderedParams) Del(key string)
- func (o *OrderedParams) Encode() string
- func (o *OrderedParams) Get(key string) string
- func (o *OrderedParams) GetAll(key string) []string
- func (o *OrderedParams) Has(key string) bool
- func (o *OrderedParams) IsEmpty() bool
- func (o *OrderedParams) Iterate(f func(key string, value []string) bool)
- func (o *OrderedParams) Merge(raw string)
- func (o *OrderedParams) Set(key string, value string)
- func (o *OrderedParams) Update(key string, value []string)
- type Params
- func (p Params) Add(key string, value ...string)
- func (p Params) Decode(raw string)
- func (p Params) Del(key string)
- func (p Params) Encode() string
- func (p Params) Get(key string) string
- func (p Params) Has(key string) bool
- func (p Params) Merge(x Params)
- func (p Params) Set(key string, value string)
- type URL
- func (u *URL) Clone() *URL
- func (u *URL) EscapedString() string
- func (u *URL) GetRelativePath() string
- func (u *URL) MergePath(newrelpath string, unsafe bool) error
- func (u *URL) Query() *OrderedParams
- func (u *URL) String() string
- func (u *URL) TrimPort()
- func (u *URL) Update()
- func (u *URL) UpdatePort(newport string)
- func (u *URL) UpdateRelPath(newrelpath string, unsafe bool) error
Constants ¶
const ( HTTP = "http" HTTPS = "https" SchemeSeparator = "://" DefaultHTTPPort = "80" DefaultHTTPSPort = "443" )
Variables ¶
var AllowLegacySeperator bool = false
Legacy Seperator (i.e `;`) is used as seperator for parameters this was removed in go >=1.17
var DisableAutoCorrect bool
disables autocorrect related to parsing Ex: if input is admin url.Parse considers admin as host which is not a valid domain name
var MustEscapeCharSet []rune = []rune{'?', '#', '@', ';', '&', ',', '[', ']', '^'}
MustEscapeCharSet are special chars that are always escaped and are based on reserved chars from RFC Some of Reserved Chars From RFC were excluded and some were added for various reasons and goal here is to encode parameters key and value only
var RFCEscapeCharSet []rune = []rune{'!', '*', '\'', '(', ')', ';', ':', '@', '&', '=', '+', '$', ',', '/', '?', '%', '#', '[', ']'}
Reserved Chars from RFC ! * ' ( ) ; : @ & = + $ , / ? % # [ ]
Functions ¶
func AutoMergeRelPaths ¶
AutoMergeRelPaths merges two relative paths including parameters and returns final string
func ParamEncode ¶
ParamEncode encodes Key characters only. key characters include whitespaces + non printable chars + non-ascii also this does not double encode encoded characters
func PercentEncoding ¶
PercentEncoding encodes all characters to percent encoded format just like burpsuite decoder
func URLEncodeWithEscapes ¶
URLEncodeWithEscapes URL encodes data with given special characters escaped (similar to burpsuite intruder) Note `MustEscapeCharSet` is not included
Types ¶
type OrderedParams ¶
type OrderedParams struct {
// contains filtered or unexported fields
}
OrderedParams is a map that preserves the order of elements
func NewOrderedParams ¶
func NewOrderedParams() *OrderedParams
NewOrderedParams creates a new ordered params
func (*OrderedParams) Add ¶
func (o *OrderedParams) Add(key string, value ...string)
Add Parameters to store
func (*OrderedParams) Clone ¶
func (o *OrderedParams) Clone() *OrderedParams
Clone returns a copy of the ordered params
func (*OrderedParams) Decode ¶
func (o *OrderedParams) Decode(raw string)
Decode is opposite of Encode() where ("bar=baz&foo=quux") is parsed Parameters are loosely parsed to allow any scenario
func (*OrderedParams) Del ¶
func (o *OrderedParams) Del(key string)
Del deletes values associated with key
func (*OrderedParams) Encode ¶
func (o *OrderedParams) Encode() string
Encode returns encoded parameters by preserving order
func (*OrderedParams) Get ¶
func (o *OrderedParams) Get(key string) string
Get returns first value of given key
func (*OrderedParams) GetAll ¶
func (o *OrderedParams) GetAll(key string) []string
GetAll returns all values of given key or returns empty slice if key doesn't exist
func (*OrderedParams) Has ¶
func (o *OrderedParams) Has(key string) bool
Has returns if given key exists
func (*OrderedParams) IsEmpty ¶
func (o *OrderedParams) IsEmpty() bool
IsEmpty checks if the OrderedParams is empty
func (*OrderedParams) Iterate ¶
func (o *OrderedParams) Iterate(f func(key string, value []string) bool)
Iterate iterates over the OrderedParams
func (*OrderedParams) Merge ¶
func (o *OrderedParams) Merge(raw string)
Merges given paramset into existing one with base as priority
func (*OrderedParams) Set ¶
func (o *OrderedParams) Set(key string, value string)
Set sets the key to value and replaces if already exists
func (*OrderedParams) Update ¶
func (o *OrderedParams) Update(key string, value []string)
Update is similar to Set but it takes value as slice (similar to internal implementation of url.Values)
type Params ¶
func (Params) Decode ¶
Decode is opposite of Encode() where ("bar=baz&foo=quux") is parsed Parameters are loosely parsed to allow any scenario
type URL ¶
type URL struct { *url.URL Original string // original or given url(without params if any) Unsafe bool // If request is unsafe (skip validation) IsRelative bool // If URL is relative Params *OrderedParams // Query Parameters }
URL a wrapper around net/url.URL
func ParseRelativePath ¶
ParseRelativePath parses and returns relative path
func (*URL) EscapedString ¶
EscapedString returns a string that can be used as filename (i.e stripped of / and params etc)
func (*URL) GetRelativePath ¶
GetRelativePath ex: /some/path?param=true#fragment