mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 00:01:10 +08:00
Merge pull request #124 from WJQSERVER-STUDIO/dev
Some checks are pending
Build / prepare (push) Waiting to run
Build / build (amd64, darwin) (push) Blocked by required conditions
Build / build (amd64, freebsd) (push) Blocked by required conditions
Build / build (amd64, linux) (push) Blocked by required conditions
Build / build (arm64, darwin) (push) Blocked by required conditions
Build / build (arm64, freebsd) (push) Blocked by required conditions
Build / build (arm64, linux) (push) Blocked by required conditions
Build / docker (push) Blocked by required conditions
Some checks are pending
Build / prepare (push) Waiting to run
Build / build (amd64, darwin) (push) Blocked by required conditions
Build / build (amd64, freebsd) (push) Blocked by required conditions
Build / build (amd64, linux) (push) Blocked by required conditions
Build / build (arm64, darwin) (push) Blocked by required conditions
Build / build (arm64, freebsd) (push) Blocked by required conditions
Build / build (arm64, linux) (push) Blocked by required conditions
Build / docker (push) Blocked by required conditions
3.5.5
This commit is contained in:
commit
c13dd9082b
5 changed files with 45 additions and 10 deletions
|
|
@ -1,5 +1,14 @@
|
|||
# 更新日志
|
||||
|
||||
3.5.5 - 2025-06-14
|
||||
---
|
||||
- CHANGE: 修正新匹配器的覆盖问题, 同时增加test的覆盖
|
||||
|
||||
25w47a - 2025-06-14
|
||||
---
|
||||
- PRE-RELEASE: 此版本是v3.5.5预发布版本,请勿在生产环境中使用;
|
||||
- CHANGE: 修正新匹配器的覆盖问题, 同时增加test的覆盖
|
||||
|
||||
3.5.4 - 2025-06-14
|
||||
---
|
||||
- CHANGE: 移植来自于[GHProxy-Touka](https://github.com/WJQSERVER-STUDIO/ghproxy-touka)的blob处理逻辑与302处理逻辑
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
25w46c
|
||||
25w47a
|
||||
2
VERSION
2
VERSION
|
|
@ -1 +1 @@
|
|||
3.5.4
|
||||
3.5.5
|
||||
|
|
@ -13,10 +13,12 @@ var (
|
|||
githubPrefix = "https://github.com/"
|
||||
rawPrefix = "https://raw.githubusercontent.com/"
|
||||
gistPrefix = "https://gist.github.com/"
|
||||
gistContentPrefix = "https://gist.githubusercontent.com/"
|
||||
apiPrefix = "https://api.github.com/"
|
||||
githubPrefixLen int
|
||||
rawPrefixLen int
|
||||
gistPrefixLen int
|
||||
gistContentPrefixLen int
|
||||
apiPrefixLen int
|
||||
)
|
||||
|
||||
|
|
@ -25,6 +27,7 @@ func init() {
|
|||
rawPrefixLen = len(rawPrefix)
|
||||
gistPrefixLen = len(gistPrefix)
|
||||
apiPrefixLen = len(apiPrefix)
|
||||
gistContentPrefixLen = len(gistContentPrefix)
|
||||
//log.Printf("githubPrefixLen: %d, rawPrefixLen: %d, gistPrefixLen: %d, apiPrefixLen: %d", githubPrefixLen, rawPrefixLen, gistPrefixLen, apiPrefixLen)
|
||||
}
|
||||
|
||||
|
|
@ -114,6 +117,23 @@ func Matcher(rawPath string, cfg *config.Config) (string, string, string, *GHPro
|
|||
return user, "", "gist", nil
|
||||
}
|
||||
|
||||
// 匹配 "https://gist.githubusercontent.com/"
|
||||
if strings.HasPrefix(rawPath, gistContentPrefix) {
|
||||
remaining := rawPath[gistContentPrefixLen:]
|
||||
i := strings.IndexByte(remaining, '/')
|
||||
if i <= 0 {
|
||||
// case: https://gist.githubusercontent.com/user
|
||||
// 这种情况下, gist_id 缺失, 但我们仍然可以认为 user 是有效的
|
||||
if len(remaining) > 0 {
|
||||
return remaining, "", "gist", nil
|
||||
}
|
||||
return "", "", "", NewErrorWithStatusLookup(400, "malformed gist url: missing user")
|
||||
}
|
||||
// case: https://gist.githubusercontent.com/user/gist_id...
|
||||
user := remaining[:i]
|
||||
return user, "", "gist", nil
|
||||
}
|
||||
|
||||
// 匹配 "https://api.github.com/"
|
||||
if strings.HasPrefix(rawPath, apiPrefix) {
|
||||
if !cfg.Auth.ForceAllowApi && (cfg.Auth.Method != "header" || !cfg.Auth.Enabled) {
|
||||
|
|
|
|||
|
|
@ -87,6 +87,12 @@ func TestMatcher_Compatibility(t *testing.T) {
|
|||
config: cfgWithAuth,
|
||||
expectedUser: "user", expectedRepo: "", expectedMatcher: "gist",
|
||||
},
|
||||
{
|
||||
name: "Gist UserContent Path",
|
||||
rawPath: "https://gist.githubusercontent.com/user/abcdef1234567890",
|
||||
config: cfgWithAuth,
|
||||
expectedUser: "user", expectedRepo: "", expectedMatcher: "gist",
|
||||
},
|
||||
{
|
||||
name: "API Repos Path (with Auth)",
|
||||
rawPath: "https://api.github.com/repos/owner/repo/pulls",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue