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 55package markup
66
77import (
8- "bytes"
98 "crypto/hmac"
109 "crypto/sha1"
1110 "encoding/base64"
@@ -16,18 +15,17 @@ import (
1615)
1716
1817// 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 {
2120 return link
2221 }
2322
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
2725 macSum := b64encode (mac .Sum (nil ))
28- encodedURL := b64encode (link )
26+ encodedURL := b64encode ([] byte ( link ) )
2927
30- return [] byte ( util .URLJoin (setting .CamoServerURL , macSum , encodedURL ) )
28+ return util .URLJoin (setting .CamoServerURL , macSum , encodedURL )
3129}
3230
3331func b64encode (data []byte ) string {
You can’t perform that action at this time.
0 commit comments