Fix trailing slash issue
This commit is contained in:
10
main.go
10
main.go
@@ -103,6 +103,9 @@ fsPath := filepath.Join(h.root, filepath.FromSlash(urlPath))
|
|||||||
}
|
}
|
||||||
|
|
||||||
if info.IsDir() {
|
if info.IsDir() {
|
||||||
|
if urlPath != "/" {
|
||||||
|
urlPath += "/"
|
||||||
|
}
|
||||||
h.serveDir(w, r, urlPath, fsPath)
|
h.serveDir(w, r, urlPath, fsPath)
|
||||||
} else {
|
} else {
|
||||||
http.ServeFile(w, r, fsPath)
|
http.ServeFile(w, r, fsPath)
|
||||||
@@ -133,17 +136,12 @@ func (h *handler) serveDir(w http.ResponseWriter, r *http.Request, urlPath, fsPa
|
|||||||
entries = listEntries(fsPath, urlPath)
|
entries = listEntries(fsPath, urlPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
postURL := urlPath
|
|
||||||
if urlPath == "/" {
|
|
||||||
postURL = "/"
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pageData{
|
data := pageData{
|
||||||
Title: pageTitle(urlPath),
|
Title: pageTitle(urlPath),
|
||||||
Crumbs: buildCrumbs(urlPath),
|
Crumbs: buildCrumbs(urlPath),
|
||||||
CanEdit: true,
|
CanEdit: true,
|
||||||
EditMode: editMode,
|
EditMode: editMode,
|
||||||
PostURL: postURL,
|
PostURL: urlPath,
|
||||||
RawContent: string(rawMD),
|
RawContent: string(rawMD),
|
||||||
Content: rendered,
|
Content: rendered,
|
||||||
Entries: entries,
|
Entries: entries,
|
||||||
|
|||||||
Reference in New Issue
Block a user