Reduce code for handling titles

This commit is contained in:
Eliot Whalan 2016-07-04 10:38:12 +10:00
parent 2d4d7034b0
commit 741511897c
No known key found for this signature in database
GPG Key ID: C0A42175139840D6
1 changed files with 3 additions and 5 deletions

View File

@ -158,12 +158,10 @@ func save(raw string, lang string, title string, expiry string) Response {
stmt, err := db.Prepare("INSERT INTO pastebin(id, title, hash, data, delkey, expiry) values(?,?,?,?,?,?)")
check(err)
if title == "" {
_, err = stmt.Exec(id, id, sha, dataEscaped, delKey, expiryTime)
check(err)
} else {
title = id
}
_, err = stmt.Exec(id, html.EscapeString(title), sha, dataEscaped, delKey, expiryTime)
check(err)
}
return Response{id, title, sha, url, len(dataEscaped), delKey}
}