-
Notifications
You must be signed in to change notification settings - Fork 31
/
url.go
68 lines (51 loc) · 1.13 KB
/
url.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package processors
import (
"net/url"
)
// URLEncode encode url string
type URLEncode struct{}
func (p URLEncode) Name() string {
return "url-encode"
}
func (p URLEncode) Alias() []string {
return []string{"url-enc"}
}
func (p URLEncode) Transform(data []byte, _ ...Flag) (string, error) {
return url.QueryEscape(string(data)), nil
}
func (p URLEncode) Flags() []Flag {
return nil
}
func (p URLEncode) Title() string {
return "URL Encode"
}
func (p URLEncode) Description() string {
return "Encode URL entities"
}
func (p URLEncode) FilterValue() string {
return p.Title()
}
// URLDecode decode url string
type URLDecode struct{}
func (p URLDecode) Name() string {
return "url-decode"
}
func (p URLDecode) Alias() []string {
return []string{"url-dec"}
}
func (p URLDecode) Transform(data []byte, _ ...Flag) (string, error) {
res, _ := url.QueryUnescape(string(data))
return res, nil
}
func (p URLDecode) Flags() []Flag {
return nil
}
func (p URLDecode) Title() string {
return "URL Decode"
}
func (p URLDecode) Description() string {
return "Decode URL entities"
}
func (p URLDecode) FilterValue() string {
return p.Title()
}