Update handler.go

This commit is contained in:
上海明馨科技有限公司 2020-09-20 07:20:18 +08:00 committed by GitHub
parent 9f2c5dc606
commit 670eba9d84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -156,7 +156,7 @@ func (handler Driver) Source(
finalURL, err := handler.getFinalURL(cachedURL.(string))
if err != nil {
return "", err
}
}
return finalURL, nil
}
// 缓存不存在,重新获取
@ -176,12 +176,19 @@ func (handler Driver) Source(
}
return "", err
}
//增加国际版反向代理自定义前缀
func (handler Driver) getFinalURL(key string)(string, error){
cdnURL, err := url.Parse(handler.Policy.BaseURL)
if err != nil {
return "", err
}
if cdnURL.String() == "https://login.chinacloudapi.cn/common/oauth2" {
return key, err
}
if cdnURL.String() == "https://login.microsoftonline.com/common/oauth2" {
return key, err
}
if cdnURL.String() != "" {
finalURL, err := url.Parse(key)
if err != nil {
@ -191,6 +198,7 @@ func (handler Driver) getFinalURL(key string)(string, error){
finalURL.Scheme = cdnURL.Scheme
return finalURL.String(), err
}
return key, err
}