Reduce code for handling titles
This commit is contained in:
parent
55fc7e2e9c
commit
3e92d60ad1
|
@ -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(?,?,?,?,?,?)")
|
stmt, err := db.Prepare("INSERT INTO pastebin(id, title, hash, data, delkey, expiry) values(?,?,?,?,?,?)")
|
||||||
check(err)
|
check(err)
|
||||||
if title == "" {
|
if title == "" {
|
||||||
_, err = stmt.Exec(id, id, sha, dataEscaped, delKey, expiryTime)
|
title = id
|
||||||
check(err)
|
|
||||||
} else {
|
|
||||||
_, err = stmt.Exec(id, html.EscapeString(title), sha, dataEscaped, delKey, expiryTime)
|
|
||||||
check(err)
|
|
||||||
}
|
}
|
||||||
|
_, err = stmt.Exec(id, html.EscapeString(title), sha, dataEscaped, delKey, expiryTime)
|
||||||
|
check(err)
|
||||||
return Response{id, title, sha, url, len(dataEscaped), delKey}
|
return Response{id, title, sha, url, len(dataEscaped), delKey}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue