forked from jason/cpolis
Change filepaths to use filepath.Join() where possible
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/google/uuid"
|
||||
b "streifling.com/jason/cpolis/cmd/backend"
|
||||
@ -56,8 +57,8 @@ func ServeArticle(c *b.Config, db *b.DB) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
articleAbsName := fmt.Sprint(c.ArticleDir, "/", article.UUID, ".md")
|
||||
contentBytes, err := os.ReadFile(articleAbsName)
|
||||
articlePath := filepath.Join(c.ArticleDir, fmt.Sprint(article.UUID, ".md"))
|
||||
contentBytes, err := os.ReadFile(articlePath)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
b "streifling.com/jason/cpolis/cmd/backend"
|
||||
)
|
||||
@ -42,6 +43,6 @@ func ServePDF(c *b.Config) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
http.ServeFile(w, r, c.PDFDir+"/"+r.PathValue("id"))
|
||||
http.ServeFile(w, r, filepath.Join(c.PDFDir, r.PathValue("id")))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user