Fix panic with non-POST requests on /bookmarks

This commit is contained in:
Maurizio Porrato 2021-05-17 22:44:42 +01:00
parent 496cc86933
commit 8e9d6197c5
Signed by: guru
GPG Key ID: C622977DF024AC24
1 changed files with 10 additions and 5 deletions

View File

@ -160,13 +160,18 @@ func updateSync(syncId string, w http.ResponseWriter, req *http.Request) {
func bookmarks(w http.ResponseWriter, req *http.Request) {
elements := strings.Split(strings.Trim(req.URL.Path, "/"), "/")
if len(elements) == 1 && req.Method == "POST" {
log.Println("createSync()")
createSync(w, req)
return
if len(elements) == 1 {
if req.Method == "POST" {
log.Println("createSync()")
createSync(w, req)
return
} else {
sendJSONError(w, syncstore.MethodNotImplementedError)
return
}
}
syncId := elements[1]
if !sidRe.MatchString(elements[1]) {
if !sidRe.MatchString(syncId) {
sendJSONError(w, syncstore.NotImplementedError)
return
}