This commit is contained in:
WJQSERVER 2024-10-24 01:46:03 +08:00
parent a8af0fb687
commit 3489e6d744
4 changed files with 16 additions and 3 deletions

View file

@ -1,5 +1,11 @@
# 更新日志
24w19b
---
- PRE-RELEASE: 此版本是v1.6.1的预发布版本,请勿在生产环境中使用
- FIX: 修复`sizeLimit`单位更改导致API返回值错误的问题
- FIX: 尝试修正Gist匹配
24w19a
---
- PRE-RELEASE: 此版本是v1.6.1的预发布版本,请勿在生产环境中使用

View file

@ -1 +1 @@
24w19a
24w19b

View file

@ -45,7 +45,7 @@ func InitHandleRouter(cfg *config.Config, router *gin.Engine) {
}
func SizeLimitHandler(cfg *config.Config, c *gin.Context) {
sizeLimit := cfg.Server.SizeLimit / 1024 / 1024
sizeLimit := cfg.Server.SizeLimit
c.Writer.Header().Set("Content-Type", "application/json")
json.NewEncoder(c.Writer).Encode(map[string]interface{}{
"MaxResponseBodySize": sizeLimit,

View file

@ -106,8 +106,15 @@ func NoRouteHandler(cfg *config.Config) gin.HandlerFunc {
}
}
// 提取用户名和仓库名,格式为 handle/<username>/<repo>/*
func MatchUserRepo(rawPath string, cfg *config.Config, c *gin.Context, matches []string) (string, string) {
// 提取用户名和仓库名,格式为 handle/<username>/<repo>/*
var gistregex = regexp.MustCompile(`^(?:https?://)?gist\.github\.com/([^/]+)/([^/]+)/.*`)
var gistmatches []string
if gistregex.MatchString(rawPath) {
gistmatches = gistregex.FindStringSubmatch(rawPath)
logInfo("Gist Matched > Username: %s, URL: %s", gistmatches[2], rawPath)
return gistmatches[2], ""
}
pathmatches := regexp.MustCompile(`^([^/]+)/([^/]+)/([^/]+)/.*`)
pathParts := pathmatches.FindStringSubmatch(matches[2])