File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change 5
5
package markup
6
6
7
7
import (
8
- "bytes"
9
8
"crypto/hmac"
10
9
"crypto/sha1"
11
10
"encoding/base64"
@@ -16,18 +15,17 @@ import (
16
15
)
17
16
18
17
// CamoEncode encodes a lnk to fit with the go-camo and camo proxy links
19
- func CamoEncode (link [] byte ) [] byte {
20
- if bytes .HasPrefix (link , [] byte ( setting .CamoServerURL ) ) || len (setting .CamoHMACKey ) == 0 {
18
+ func CamoEncode (link string ) string {
19
+ if strings .HasPrefix (link , setting .CamoServerURL ) || len (setting .CamoHMACKey ) == 0 {
21
20
return link
22
21
}
23
22
24
- hmacKey := []byte (setting .CamoHMACKey )
25
- mac := hmac .New (sha1 .New , hmacKey )
26
- _ , _ = mac .Write (link ) // hmac does not return errors
23
+ mac := hmac .New (sha1 .New , []byte (setting .CamoHMACKey ))
24
+ _ , _ = mac .Write ([]byte (link )) // hmac does not return errors
27
25
macSum := b64encode (mac .Sum (nil ))
28
- encodedURL := b64encode (link )
26
+ encodedURL := b64encode ([] byte ( link ) )
29
27
30
- return [] byte ( util .URLJoin (setting .CamoServerURL , macSum , encodedURL ) )
28
+ return util .URLJoin (setting .CamoServerURL , macSum , encodedURL )
31
29
}
32
30
33
31
func b64encode (data []byte ) string {
You can’t perform that action at this time.
0 commit comments