mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
fix: tag regexp (#409)
* chore: enable `no-unused-vars` * fix: tag regexp
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
var tagRegexp = regexp.MustCompile(`[^\s]?#([^\s#]+?) `)
|
var tagRegexpList = []*regexp.Regexp{regexp.MustCompile(`^#([^\s#]+?) `), regexp.MustCompile(`\s#([^\s#]+?) `)}
|
||||||
|
|
||||||
func (s *Server) registerTagRoutes(g *echo.Group) {
|
func (s *Server) registerTagRoutes(g *echo.Group) {
|
||||||
g.GET("/tag", func(c echo.Context) error {
|
g.GET("/tag", func(c echo.Context) error {
|
||||||
@@ -50,9 +50,11 @@ func (s *Server) registerTagRoutes(g *echo.Group) {
|
|||||||
tagMapSet := make(map[string]bool)
|
tagMapSet := make(map[string]bool)
|
||||||
|
|
||||||
for _, memo := range memoList {
|
for _, memo := range memoList {
|
||||||
for _, rawTag := range tagRegexp.FindAllString(memo.Content, -1) {
|
for _, tagRegexp := range tagRegexpList {
|
||||||
tag := tagRegexp.ReplaceAllString(rawTag, "$1")
|
for _, rawTag := range tagRegexp.FindAllString(memo.Content, -1) {
|
||||||
tagMapSet[tag] = true
|
tag := tagRegexp.ReplaceAllString(rawTag, "$1")
|
||||||
|
tagMapSet[tag] = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user