Skip to content

Commit 79f4f96

Browse files
authored
feat(strm):add sign and encode path options (#537)
1 parent 7f53390 commit 79f4f96

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

drivers/strm/meta.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import (
77

88
type Addition struct {
99
Paths string `json:"paths" required:"true" type:"text"`
10-
ProtectSameName bool `json:"protect_same_name" default:"true" required:"false" help:"Protects same-name files from Delete or Rename"`
1110
SiteUrl string `json:"siteUrl" type:"text" required:"false" help:"The prefix URL of the strm file"`
1211
FilterFileTypes string `json:"filterFileTypes" type:"text" default:"strm" required:"false" help:"Supports suffix name of strm file"`
12+
UseSign bool `json:"signPath" default:"true" required:"true" help:"sign the path in the strm file"`
13+
EncodePath bool `json:"encodePath" default:"true" required:"true" help:"encode the path in the strm file"`
1314
}
1415

1516
var config = driver.Config{
@@ -24,6 +25,11 @@ var config = driver.Config{
2425

2526
func init() {
2627
op.RegisterDriver(func() driver.Driver {
27-
return &Strm{}
28+
return &Strm{
29+
Addition: Addition{
30+
UseSign: true,
31+
EncodePath: true,
32+
},
33+
}
2834
})
2935
}

drivers/strm/util.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,16 @@ func (d *Strm) getLink(ctx context.Context, path string) string {
133133
} else {
134134
apiUrl = common.GetApiUrl(ctx)
135135
}
136+
137+
if d.EncodePath {
138+
path = utils.EncodePath(path, true)
139+
}
140+
if !d.UseSign {
141+
return fmt.Sprintf("%s/d%s", apiUrl, path)
142+
}
143+
136144
return fmt.Sprintf("%s/d%s?sign=%s",
137145
apiUrl,
138-
utils.EncodePath(path, true),
146+
path,
139147
sign.Sign(path))
140148
}

0 commit comments

Comments
 (0)