Fix title is empty when adding bookmark

This commit is contained in:
Radhi Fadlillah 2019-10-03 20:23:28 +07:00
parent 035658d405
commit 28ee496a68
2 changed files with 10 additions and 0 deletions

View file

@ -104,6 +104,11 @@ func addHandler(cmd *cobra.Command, args []string) {
}
}
// Make sure bookmark's title not empty
if book.Title == "" {
book.Title = book.URL
}
// Save bookmark to database
_, err = db.SaveBookmarks(book)
if err != nil {

View file

@ -278,6 +278,11 @@ func (h *handler) apiInsertBookmark(w http.ResponseWriter, r *http.Request, ps h
}
}
// Make sure bookmark's title not empty
if book.Title == "" {
book.Title = book.URL
}
// Save bookmark to database
results, err := h.DB.SaveBookmarks(book)
if err != nil || len(results) == 0 {