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 ¶ added in v0.0.6
AutoMergeRelPaths merges two relative paths including parameters and returns final string
func ParamEncode ¶ added in v0.0.4
ParamEncode encodes Key characters only. key characters include whitespaces + non printable chars + non-ascii also this does not double encode encoded characters
func PercentEncoding ¶ added in v0.0.4
PercentEncoding encodes all characters to percent encoded format just like burpsuite decoder
func URLEncodeWithEscapes ¶ added in v0.0.4
URLEncodeWithEscapes URL encodes data with given special characters escaped (similar to burpsuite intruder) Note `MustEscapeCharSet` is not included
Types ¶
type OrderedParams ¶ added in v0.0.40
type OrderedParams struct {
// contains filtered or unexported fields
}
OrderedParams is a map that preserves the order of elements
func NewOrderedParams ¶ added in v0.0.40
func NewOrderedParams() *OrderedParams
NewOrderedParams creates a new ordered params
func (*OrderedParams) Add ¶ added in v0.0.40
func (o *OrderedParams) Add(key string, value ...string)
Add Parameters to store
func (*OrderedParams) Clone ¶ added in v0.0.40
func (o *OrderedParams) Clone() *OrderedParams
Clone returns a copy of the ordered params
func (*OrderedParams) Decode ¶ added in v0.0.40
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 ¶ added in v0.0.40
func (o *OrderedParams) Del(key string)
Del deletes values associated with key
func (*OrderedParams) Encode ¶ added in v0.0.40
func (o *OrderedParams) Encode() string
Encode returns encoded parameters by preserving order
func (*OrderedParams) Get ¶ added in v0.0.40
func (o *OrderedParams) Get(key string) string
Get returns first value of given key
func (*OrderedParams) GetAll ¶ added in v0.0.40
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 ¶ added in v0.0.40
func (o *OrderedParams) Has(key string) bool
Has returns if given key exists
func (*OrderedParams) IsEmpty ¶ added in v0.0.40
func (o *OrderedParams) IsEmpty() bool
IsEmpty checks if the OrderedParams is empty
func (*OrderedParams) Iterate ¶ added in v0.0.40
func (o *OrderedParams) Iterate(f func(key string, value []string) bool)
Iterate iterates over the OrderedParams
func (*OrderedParams) Merge ¶ added in v0.0.40
func (o *OrderedParams) Merge(raw string)
Merges given paramset into existing one with base as priority
func (*OrderedParams) Set ¶ added in v0.0.40
func (o *OrderedParams) Set(key string, value string)
Set sets the key to value and replaces if already exists
func (*OrderedParams) Update ¶ added in v0.0.40
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 ¶ added in v0.0.4
func (Params) Decode ¶ added in v0.0.4
Decode is opposite of Encode() where ("bar=baz&foo=quux") is parsed Parameters are loosely parsed to allow any scenario
func (Params) Encode ¶ added in v0.0.4
Encode URL encodes and returns values ("bar=baz&foo=quux") sorted by key.
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 ¶ added in v0.0.8
ParseRelativePath parses and returns relative path
func (*URL) EscapedString ¶ added in v0.0.8
EscapedString returns a string that can be used as filename (i.e stripped of / and params etc)
func (*URL) GetRelativePath ¶ added in v0.0.6
GetRelativePath ex: /some/path?param=true#fragment