mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 08:11:11 +08:00
24w19b
This commit is contained in:
parent
3489e6d744
commit
0c1eb34e49
1 changed files with 4 additions and 4 deletions
|
|
@ -30,7 +30,7 @@ var exps = []*regexp.Regexp{
|
||||||
regexp.MustCompile(`^(?:https?://)?github\.com/([^/]+)/([^/]+)/(?:blob|raw)/.*`),
|
regexp.MustCompile(`^(?:https?://)?github\.com/([^/]+)/([^/]+)/(?:blob|raw)/.*`),
|
||||||
regexp.MustCompile(`^(?:https?://)?github\.com/([^/]+)/([^/]+)/(?:info|git-).*`),
|
regexp.MustCompile(`^(?:https?://)?github\.com/([^/]+)/([^/]+)/(?:info|git-).*`),
|
||||||
regexp.MustCompile(`^(?:https?://)?raw\.github(?:usercontent|)\.com/([^/]+)/([^/]+)/.+?/.+`),
|
regexp.MustCompile(`^(?:https?://)?raw\.github(?:usercontent|)\.com/([^/]+)/([^/]+)/.+?/.+`),
|
||||||
regexp.MustCompile(`^(?:https?://)?gist\.github\.com/([^/]+)/.+?/.+`),
|
regexp.MustCompile(`^(?:https?://)?gist\.github(?:usercontent|)\.com/([^/]+)/.+?/.+`),
|
||||||
}
|
}
|
||||||
|
|
||||||
func NoRouteHandler(cfg *config.Config) gin.HandlerFunc {
|
func NoRouteHandler(cfg *config.Config) gin.HandlerFunc {
|
||||||
|
|
@ -108,12 +108,12 @@ func NoRouteHandler(cfg *config.Config) gin.HandlerFunc {
|
||||||
|
|
||||||
// 提取用户名和仓库名,格式为 handle/<username>/<repo>/*
|
// 提取用户名和仓库名,格式为 handle/<username>/<repo>/*
|
||||||
func MatchUserRepo(rawPath string, cfg *config.Config, c *gin.Context, matches []string) (string, string) {
|
func MatchUserRepo(rawPath string, cfg *config.Config, c *gin.Context, matches []string) (string, string) {
|
||||||
var gistregex = regexp.MustCompile(`^(?:https?://)?gist\.github\.com/([^/]+)/([^/]+)/.*`)
|
var gistregex = regexp.MustCompile(`^(?:https?://)?gist\.github(?:usercontent|)\.com/([^/]+)/([^/]+)/.*`)
|
||||||
var gistmatches []string
|
var gistmatches []string
|
||||||
if gistregex.MatchString(rawPath) {
|
if gistregex.MatchString(rawPath) {
|
||||||
gistmatches = gistregex.FindStringSubmatch(rawPath)
|
gistmatches = gistregex.FindStringSubmatch(rawPath)
|
||||||
logInfo("Gist Matched > Username: %s, URL: %s", gistmatches[2], rawPath)
|
logInfo("Gist Matched > Username: %s, URL: %s", gistmatches[1], rawPath)
|
||||||
return gistmatches[2], ""
|
return gistmatches[1], ""
|
||||||
}
|
}
|
||||||
pathmatches := regexp.MustCompile(`^([^/]+)/([^/]+)/([^/]+)/.*`)
|
pathmatches := regexp.MustCompile(`^([^/]+)/([^/]+)/([^/]+)/.*`)
|
||||||
pathParts := pathmatches.FindStringSubmatch(matches[2])
|
pathParts := pathmatches.FindStringSubmatch(matches[2])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue