refactor constants
alex wennerberg alex@alexwennerberg.com
Wed, 30 Dec 2020 10:50:53 -0800
M
db.go
→
db.go
@@ -118,7 +118,7 @@ if err != nil {
log.Printf("Failure accessing a path %q: %v\n", thepath, err) return err // think about } - if !admin && info.IsDir() && info.Name() == HIDDEN_FOLDER { + if !admin && info.IsDir() && info.Name() == HiddenFolder { return filepath.SkipDir } // make this do what it should
M
gemfeed.go
→
gemfeed.go
@@ -17,8 +17,6 @@ "strings"
"time" ) -const gemlogFolder = "gemlog" - type Gemfeed struct { Title string Creator string@@ -64,7 +62,7 @@
// Non-standard extension // Requires yyyy-mm-dd formatted files func generateFeedFromUser(user string) *Gemfeed { - gemlogFolderPath := path.Join(c.FilesDirectory, user, gemlogFolder) + gemlogFolderPath := path.Join(c.FilesDirectory, user, GemlogFolder) // NOTE: assumes sanitized input u := urlFromPath(gemlogFolderPath) feed := Gemfeed{
M
gemini.go
→
gemini.go
@@ -83,7 +83,7 @@ userName := filepath.Clean(strings.Split(r.URL.Host, ".")[0]) // clean probably unnecessary
fileName := filepath.Clean(r.URL.Path) if fileName == "/" { fileName = "index.gmi" - } else if strings.HasPrefix(fileName, "/.hidden") { + } else if strings.HasPrefix(fileName, "/"+HiddenFolder) { w.WriteStatus(gmi.StatusNotFound) return }