ensure trailing slash on entries to avoid duplicate urls
This commit is contained in:
parent
30e54f99fb
commit
8d3bdb6f4c
|
@ -7,7 +7,7 @@
|
|||
<div class="h-entry">
|
||||
<hgroup>
|
||||
<h3>
|
||||
<a class="u-url" href="/posts/{{ .ID }}">
|
||||
<a class="u-url" href="/posts/{{ .ID }}/">
|
||||
{{if .Title}}
|
||||
{{ .Title }}
|
||||
{{else}}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package web
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"owl-blogs/app"
|
||||
"owl-blogs/app/repository"
|
||||
"owl-blogs/domain/model"
|
||||
|
@ -43,6 +44,11 @@ func NewEntryHandler(
|
|||
func (h *EntryHandler) Handle(c *fiber.Ctx) error {
|
||||
c.Set(fiber.HeaderContentType, fiber.MIMETextHTML)
|
||||
|
||||
url := c.OriginalURL()
|
||||
if len(url) == 0 || url[len(url)-1] != '/' {
|
||||
return c.Redirect(url+"/", http.StatusMovedPermanently)
|
||||
}
|
||||
|
||||
loggedIn := c.Locals("author") != nil
|
||||
|
||||
entryId := c.Params("post")
|
||||
|
|
Loading…
Reference in New Issue