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 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() Params
- 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 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 Params // 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