mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-07-18 17:38:07 +08:00
feat(strm):add sign and encode path options (#537)
This commit is contained in:
@ -7,9 +7,10 @@ import (
|
||||
|
||||
type Addition struct {
|
||||
Paths string `json:"paths" required:"true" type:"text"`
|
||||
ProtectSameName bool `json:"protect_same_name" default:"true" required:"false" help:"Protects same-name files from Delete or Rename"`
|
||||
SiteUrl string `json:"siteUrl" type:"text" required:"false" help:"The prefix URL of the strm file"`
|
||||
FilterFileTypes string `json:"filterFileTypes" type:"text" default:"strm" required:"false" help:"Supports suffix name of strm file"`
|
||||
UseSign bool `json:"signPath" default:"true" required:"true" help:"sign the path in the strm file"`
|
||||
EncodePath bool `json:"encodePath" default:"true" required:"true" help:"encode the path in the strm file"`
|
||||
}
|
||||
|
||||
var config = driver.Config{
|
||||
@ -24,6 +25,11 @@ var config = driver.Config{
|
||||
|
||||
func init() {
|
||||
op.RegisterDriver(func() driver.Driver {
|
||||
return &Strm{}
|
||||
return &Strm{
|
||||
Addition: Addition{
|
||||
UseSign: true,
|
||||
EncodePath: true,
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -133,8 +133,16 @@ func (d *Strm) getLink(ctx context.Context, path string) string {
|
||||
} else {
|
||||
apiUrl = common.GetApiUrl(ctx)
|
||||
}
|
||||
|
||||
if d.EncodePath {
|
||||
path = utils.EncodePath(path, true)
|
||||
}
|
||||
if !d.UseSign {
|
||||
return fmt.Sprintf("%s/d%s", apiUrl, path)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s/d%s?sign=%s",
|
||||
apiUrl,
|
||||
utils.EncodePath(path, true),
|
||||
path,
|
||||
sign.Sign(path))
|
||||
}
|
||||
|
Reference in New Issue
Block a user