mirror of https://github.com/jlelse/GoBlog
Fix date based archive routes
This commit is contained in:
parent
41511df0e5
commit
9815abf4bb
|
@ -220,17 +220,17 @@ func (a *goBlog) blogDatesRouter(conf *configBlog) func(r chi.Router) {
|
||||||
a.cacheMiddleware,
|
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, a.serveDate)
|
||||||
r.Get(yearPath+feedPath, a.serveDate)
|
r.Get(yearPath+feedPath, a.serveDate)
|
||||||
r.Get(yearPath+paginationPath, 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, a.serveDate)
|
||||||
r.Get(monthPath+feedPath, a.serveDate)
|
r.Get(monthPath+feedPath, a.serveDate)
|
||||||
r.Get(monthPath+paginationPath, 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, a.serveDate)
|
||||||
r.Get(dayPath+feedPath, a.serveDate)
|
r.Get(dayPath+feedPath, a.serveDate)
|
||||||
r.Get(dayPath+paginationPath, a.serveDate)
|
r.Get(dayPath+paginationPath, a.serveDate)
|
||||||
|
|
|
@ -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…
Reference in New Issue