From 3489e6d744ffae66d70f8579ae5af5587068e593 Mon Sep 17 00:00:00 2001 From: WJQSERVER Date: Thu, 24 Oct 2024 01:46:03 +0800 Subject: [PATCH] 24w19b --- CHANGELOG.md | 6 ++++++ DEV-VERSION | 2 +- api/api.go | 2 +- proxy/proxy.go | 9 ++++++++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa70dbf..edcb8ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # 更新日志 +24w19b +--- +- PRE-RELEASE: 此版本是v1.6.1的预发布版本,请勿在生产环境中使用 +- FIX: 修复`sizeLimit`单位更改导致API返回值错误的问题 +- FIX: 尝试修正Gist匹配 + 24w19a --- - PRE-RELEASE: 此版本是v1.6.1的预发布版本,请勿在生产环境中使用 diff --git a/DEV-VERSION b/DEV-VERSION index 2e85c10..247e25b 100644 --- a/DEV-VERSION +++ b/DEV-VERSION @@ -1 +1 @@ -24w19a \ No newline at end of file +24w19b \ No newline at end of file diff --git a/api/api.go b/api/api.go index 7dd56a0..3214d92 100644 --- a/api/api.go +++ b/api/api.go @@ -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, diff --git a/proxy/proxy.go b/proxy/proxy.go index 3f467c0..958f501 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -106,8 +106,15 @@ func NoRouteHandler(cfg *config.Config) gin.HandlerFunc { } } +// 提取用户名和仓库名,格式为 handle///* func MatchUserRepo(rawPath string, cfg *config.Config, c *gin.Context, matches []string) (string, string) { - // 提取用户名和仓库名,格式为 handle///* + 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])