mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 04:17:23 +00:00
Unescape and trim whitespace from tag name in URL handling
This commit is contained in:
@@ -2,6 +2,7 @@ package middleware
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
url2 "net/url"
|
||||
"nysoure/server/config"
|
||||
"nysoure/server/service"
|
||||
"nysoure/server/utils"
|
||||
@@ -94,12 +95,16 @@ func serveIndexHtml(c fiber.Ctx) error {
|
||||
}
|
||||
} else if strings.HasPrefix(path, "/tag/") {
|
||||
tagName := strings.TrimPrefix(path, "/tag/")
|
||||
tagName, err := url2.PathUnescape(tagName)
|
||||
tagName = strings.TrimSpace(tagName)
|
||||
if err == nil {
|
||||
t, err := service.GetTagByName(tagName)
|
||||
if err == nil {
|
||||
title = "Tag: " + t.Name
|
||||
description = utils.ArticleToDescription(t.Description, 256)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
content = strings.ReplaceAll(content, "{{SiteName}}", siteName)
|
||||
content = strings.ReplaceAll(content, "{{Description}}", description)
|
||||
|
Reference in New Issue
Block a user