mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 08:11:11 +08:00
[port] config add rewriteAPI
This commit is contained in:
parent
1498156f56
commit
b684227191
3 changed files with 10 additions and 5 deletions
|
|
@ -64,9 +64,11 @@ type GitCloneConfig struct {
|
||||||
/*
|
/*
|
||||||
[shell]
|
[shell]
|
||||||
editor = true
|
editor = true
|
||||||
|
rewriteAPI = false
|
||||||
*/
|
*/
|
||||||
type ShellConfig struct {
|
type ShellConfig struct {
|
||||||
Editor bool `toml:"editor"`
|
Editor bool `toml:"editor"`
|
||||||
|
RewriteAPI bool `toml:"rewriteAPI"`
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ ForceH2C = false
|
||||||
|
|
||||||
[shell]
|
[shell]
|
||||||
editor = false
|
editor = false
|
||||||
|
rewriteAPI = false
|
||||||
|
|
||||||
[pages]
|
[pages]
|
||||||
mode = "internal" # "internal" or "external"
|
mode = "internal" # "internal" or "external"
|
||||||
|
|
|
||||||
|
|
@ -151,10 +151,12 @@ func EditorMatcher(rawPath string, cfg *config.Config) (bool, string, error) {
|
||||||
if strings.HasPrefix(rawPath, "https://gist.github.com") {
|
if strings.HasPrefix(rawPath, "https://gist.github.com") {
|
||||||
return true, matcher, nil
|
return true, matcher, nil
|
||||||
}
|
}
|
||||||
// 匹配 "https://api.github.com/"开头的链接
|
if cfg.Shell.RewriteAPI {
|
||||||
if strings.HasPrefix(rawPath, "https://api.github.com") {
|
// 匹配 "https://api.github.com/"开头的链接
|
||||||
matcher = "api"
|
if strings.HasPrefix(rawPath, "https://api.github.com") {
|
||||||
return true, matcher, nil
|
matcher = "api"
|
||||||
|
return true, matcher, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false, "", ErrInvalidURL
|
return false, "", ErrInvalidURL
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue