mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 08:11:11 +08:00
update & fix matcher
This commit is contained in:
parent
470d1d58fa
commit
15dfab722c
1 changed files with 35 additions and 30 deletions
|
|
@ -100,7 +100,6 @@ func Matcher(rawPath string, cfg *config.Config) (string, string, string, error)
|
||||||
matcher = "gist"
|
matcher = "gist"
|
||||||
return user, repo, matcher, nil
|
return user, repo, matcher, nil
|
||||||
}
|
}
|
||||||
if cfg.Shell.RewriteAPI {
|
|
||||||
// 匹配 "https://api.github.com/"开头的链接
|
// 匹配 "https://api.github.com/"开头的链接
|
||||||
if strings.HasPrefix(rawPath, "https://api.github.com/") {
|
if strings.HasPrefix(rawPath, "https://api.github.com/") {
|
||||||
matcher = "api"
|
matcher = "api"
|
||||||
|
|
@ -121,7 +120,6 @@ func Matcher(rawPath string, cfg *config.Config) (string, string, string, error)
|
||||||
}
|
}
|
||||||
return user, repo, matcher, nil
|
return user, repo, matcher, nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return "", "", "", ErrInvalidURL
|
return "", "", "", ErrInvalidURL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -131,10 +129,12 @@ func EditorMatcher(rawPath string, cfg *config.Config) (bool, string, error) {
|
||||||
)
|
)
|
||||||
// 匹配 "https://github.com"开头的链接
|
// 匹配 "https://github.com"开头的链接
|
||||||
if strings.HasPrefix(rawPath, "https://github.com") {
|
if strings.HasPrefix(rawPath, "https://github.com") {
|
||||||
|
/*
|
||||||
remainingPath := strings.TrimPrefix(rawPath, "https://github.com")
|
remainingPath := strings.TrimPrefix(rawPath, "https://github.com")
|
||||||
if strings.HasPrefix(remainingPath, "/") {
|
if strings.HasPrefix(remainingPath, "/") {
|
||||||
remainingPath = strings.TrimPrefix(remainingPath, "/")
|
remainingPath = strings.TrimPrefix(remainingPath, "/")
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return true, "", nil
|
return true, "", nil
|
||||||
}
|
}
|
||||||
// 匹配 "https://raw.githubusercontent.com"开头的链接
|
// 匹配 "https://raw.githubusercontent.com"开头的链接
|
||||||
|
|
@ -154,19 +154,24 @@ func EditorMatcher(rawPath string, cfg *config.Config) (bool, string, error) {
|
||||||
return true, matcher, nil
|
return true, matcher, nil
|
||||||
}
|
}
|
||||||
// 匹配 "https://api.github.com/"开头的链接
|
// 匹配 "https://api.github.com/"开头的链接
|
||||||
|
if cfg.Shell.RewriteAPI {
|
||||||
if strings.HasPrefix(rawPath, "https://api.github.com") {
|
if strings.HasPrefix(rawPath, "https://api.github.com") {
|
||||||
matcher = "api"
|
matcher = "api"
|
||||||
return true, matcher, nil
|
return true, matcher, nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false, "", ErrInvalidURL
|
return false, "", ErrInvalidURL
|
||||||
}
|
}
|
||||||
|
|
||||||
// 匹配文件扩展名是sh的rawPath
|
// 匹配文件扩展名是sh的rawPath
|
||||||
func MatcherShell(rawPath string) bool {
|
func MatcherShell(rawPath string) bool {
|
||||||
|
/*
|
||||||
if strings.HasSuffix(rawPath, ".sh") {
|
if strings.HasSuffix(rawPath, ".sh") {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
*/
|
||||||
|
return strings.HasSuffix(rawPath, ".sh")
|
||||||
}
|
}
|
||||||
|
|
||||||
// LinkProcessor 是一个函数类型,用于处理提取到的链接。
|
// LinkProcessor 是一个函数类型,用于处理提取到的链接。
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue