Skip to content

Commit 34d6a8e

Browse files
retlehsclaude
andcommitted
Fix sitemap package URLs returning 404
Chi's {page} param in /sitemap-packages-{page}.xml captures "0.xml" instead of just "0", causing strconv.Atoi to fail. Strip the .xml suffix before parsing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent cc53b14 commit 34d6a8e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

internal/http/seo.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"net/http"
99
"strconv"
10+
"strings"
1011
"sync"
1112
"time"
1213

@@ -253,7 +254,8 @@ func handleSitemapPackages(a *app.App, data *sitemapData) http.HandlerFunc {
253254
return
254255
}
255256

256-
page, err := strconv.Atoi(chi.URLParam(r, "page"))
257+
pageStr := strings.TrimSuffix(chi.URLParam(r, "page"), ".xml")
258+
page, err := strconv.Atoi(pageStr)
257259
if err != nil || page < 0 {
258260
http.NotFound(w, r)
259261
return

0 commit comments

Comments
 (0)