mirror of
https://github.com/AlistGo/alist.git
synced 2025-04-23 13:54:04 +08:00
feat: add ignore direct link params (close #5434)
This commit is contained in:
parent
4fc0a77565
commit
c0f9c8ebaf
@ -139,6 +139,7 @@ func InitialSettings() []model.SettingItem {
|
||||
{Key: conf.OcrApi, Value: "https://api.nn.ci/ocr/file/json", Type: conf.TypeString, Group: model.GLOBAL},
|
||||
{Key: conf.FilenameCharMapping, Value: `{"/": "|"}`, Type: conf.TypeText, Group: model.GLOBAL},
|
||||
{Key: conf.ForwardDirectLinkParams, Value: "false", Type: conf.TypeBool, Group: model.GLOBAL},
|
||||
{Key: conf.IgnoreDirectLinkParams, Value: "sign,alist_ts", Type: conf.TypeString, Group: model.GLOBAL},
|
||||
{Key: conf.WebauthnLoginEnabled, Value: "false", Type: conf.TypeBool, Group: model.GLOBAL, Flag: model.PUBLIC},
|
||||
|
||||
// aria2 settings
|
||||
|
@ -41,6 +41,7 @@ const (
|
||||
OcrApi = "ocr_api"
|
||||
FilenameCharMapping = "filename_char_mapping"
|
||||
ForwardDirectLinkParams = "forward_direct_link_params"
|
||||
IgnoreDirectLinkParams = "ignore_direct_link_params"
|
||||
WebauthnLoginEnabled = "webauthn_login_enabled"
|
||||
|
||||
// index
|
||||
|
@ -78,6 +78,10 @@ var settingItemHooks = map[string]SettingItemHook{
|
||||
log.Debugf("filename char mapping: %+v", conf.FilenameCharMap)
|
||||
return nil
|
||||
},
|
||||
conf.IgnoreDirectLinkParams: func(item *model.SettingItem) error {
|
||||
conf.SlicesMap[conf.IgnoreDirectLinkParams] = strings.Split(item.Value, ",")
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
func RegisterSettingItemHook(key string, hook SettingItemHook) {
|
||||
|
@ -52,7 +52,9 @@ func Down(c *gin.Context) {
|
||||
c.Header("Cache-Control", "max-age=0, no-cache, no-store, must-revalidate")
|
||||
if setting.GetBool(conf.ForwardDirectLinkParams) {
|
||||
query := c.Request.URL.Query()
|
||||
query.Del("sign")
|
||||
for _, v := range conf.SlicesMap[conf.IgnoreDirectLinkParams] {
|
||||
query.Del(v)
|
||||
}
|
||||
link.URL, err = utils.InjectQuery(link.URL, query)
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 500)
|
||||
@ -95,7 +97,9 @@ func Proxy(c *gin.Context) {
|
||||
}
|
||||
if link.URL != "" && setting.GetBool(conf.ForwardDirectLinkParams) {
|
||||
query := c.Request.URL.Query()
|
||||
query.Del("sign")
|
||||
for _, v := range conf.SlicesMap[conf.IgnoreDirectLinkParams] {
|
||||
query.Del(v)
|
||||
}
|
||||
link.URL, err = utils.InjectQuery(link.URL, query)
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 500)
|
||||
|
Loading…
x
Reference in New Issue
Block a user