pico

created pr with pico/prose-redirect-slash.1 on 2026-11-27T14:44:14Z · by c8ef7d19
cmds
checkout latest patchset:
ssh pr.pico.sh pull pico:prose-redirect-slash | git am -3
checkout specific patchset revision:
ssh pr.pico.sh pull pico:prose-redirect-slash [rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pico:prose-redirect-slash
add comment to patch request:
ssh pr.pico.sh comment pico:prose-redirect-slash "lgtm!"

Patchset pico/prose-redirect-slash.1 on 2026-11-27T14:44:14Z · commit 42c357d

We treat both posts the same but any cdn/analytics will treat them as potentially
distinct so as part of best practices we collapse them with a redirect.

Prose uses the bare post as the canonical url so we want to trim the trailing
`/`.
Diff stat
pkg/apps/prose/api.go | 12 ++++++++++++
1 file changed, 12 insertions(+)
Semantic diff summary
0 added, 0 modified, 0 signature changed, 0 removed across 1 analyzed file
+12 -0 pkg/apps/prose/api.go #
......@@ -946,11 +946,23 @@ var (
946946 // A "/raw/{slug...}" pattern would redirect "/raw" away from a post named raw.
947947 func (web *webRouter) pathRoute(w http.ResponseWriter, r *http.Request) {
948948 path := r.PathValue("path")
949+
950+ // remove trailing `/` suffix and 301 redirect as part of best practices
951+ if strings.HasSuffix(path, "/") {
952+ nextUrl := fmt.Sprintf("/%s", strings.TrimSuffix(path, "/"))
953+ if r.URL.RawQuery != "" {
954+ nextUrl = fmt.Sprintf("%s?%s", nextUrl, r.URL.RawQuery)
955+ }
956+ http.Redirect(w, r, nextUrl, http.StatusMovedPermanently)
957+ return
958+ }
959+
949960 if slug, ok := strings.CutPrefix(path, "raw/"); ok && slug != "" {
950961 r.SetPathValue("slug", slug)
951962 web.postRawHandler(w, r)
952963 return
953964 }
965+
954966 for _, ext := range []string{".md", ".gmi"} {
955967 if slug, ok := strings.CutSuffix(path, ext); ok && slug != "" {
956968 r.SetPathValue("slug", slug)
Back to top