Browse Source

Fix date based archive routes

master
Jan-Lukas Else 1 month ago
parent
commit
9815abf4bb
  1. 6
      httpRouters.go
  2. 15
      search_test.go

6
httpRouters.go

@ -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

@ -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)))
}
Loading…
Cancel
Save