Fix date based archive routes

This commit is contained in:
Jan-Lukas Else 2021-11-03 18:52:41 +01:00
parent 41511df0e5
commit 9815abf4bb
2 changed files with 18 additions and 3 deletions

View File

@ -220,17 +220,17 @@ func (a *goBlog) blogDatesRouter(conf *configBlog) func(r chi.Router) {
a.cacheMiddleware,
)
yearPath := conf.getRelativePath(`/{year:x|\d\d\d\d}`)
yearPath := conf.getRelativePath(`/{year:(x|\d{4})}`)
r.Get(yearPath, a.serveDate)
r.Get(yearPath+feedPath, a.serveDate)
r.Get(yearPath+paginationPath, a.serveDate)
monthPath := yearPath + `/{month:x|\d\d}`
monthPath := yearPath + `/{month:(x|\d{2})}`
r.Get(monthPath, a.serveDate)
r.Get(monthPath+feedPath, a.serveDate)
r.Get(monthPath+paginationPath, a.serveDate)
dayPath := monthPath + `/{day:\d\d}`
dayPath := monthPath + `/{day:(\d{2})}`
r.Get(dayPath, a.serveDate)
r.Get(dayPath+feedPath, a.serveDate)
r.Get(dayPath+paginationPath, a.serveDate)

15
search_test.go Normal file
View File

@ -0,0 +1,15 @@
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_searchEncoding(t *testing.T) {
testString := "test"
assert.Equal(t, testString, searchDecode(searchEncode(testString)))
}