use https as default scheme for links

This commit is contained in:
Timon Ringwald 2022-11-23 09:58:06 +01:00
parent a5616ade77
commit 6f449301ff

13
main.go
View File

@ -159,6 +159,19 @@ func saveChanges(w http.ResponseWriter, r *http.Request) {
return
}
for _, bookmark := range sessionData.Bookmarks {
uri, err := url.Parse(bookmark.Link)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusBadRequest)
return
}
if uri.Scheme == "" {
uri.Scheme = "https"
}
bookmark.Link = uri.String()
}
Reorder(sessionData.Bookmarks)
if err := DeleteBookmarksBySessionID(session.ID); err != nil {
fmt.Println(err)