Skip to content

Commit

Permalink
wax. short url: fix base64 encoding to match standard rfc (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
edospadoni authored Dec 15, 2021
1 parent 60dad29 commit 89217d8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sun/sun-tasks/tasks/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func Init(action string, worker bool) {

func cleanAuths() {
db := database.Instance()
db.Where("updated < ?", time.Now().AddDate(0, 0, -1).UTC()).Delete(models.DaemonAuth{})
db.Where("updated < ?", time.Now().Add(-1 * time.Hour).UTC()).Delete(models.DaemonAuth{})
}

func cleanTokens() {
Expand Down
2 changes: 1 addition & 1 deletion wax/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func GenerateShortURL(longURL string, uamip string, uamport string, keepURL bool
s := fmt.Sprintf("%.7s", fmt.Sprintf("%x", h.Sum(nil)))
//Encode the first 7 digits in Base64 without padding and url safe
encoded := base64.URLEncoding.WithPadding(base64.NoPadding).EncodeToString([]byte(s))
encodedURL := base64.URLEncoding.WithPadding(base64.NoPadding).EncodeToString([]byte(longURL))
encodedURL := base64.StdEncoding.WithPadding(base64.StdPadding).EncodeToString([]byte(longURL))

db.Where("hash = ? ", encoded).First(&shortUrl)

Expand Down

0 comments on commit 89217d8

Please sign in to comment.