@@ -69,13 +69,14 @@ func AddURL(ctx context.Context, args *AddURLArgs) (task.TaskExtensionInfo, erro
6969 }
7070 // try putting url
7171 if args .Tool == "SimpleHttp" {
72+ if isSimpleHttpSchemeUnsupported (args .URL ) {
73+ return nil , fmt .Errorf ("SimpleHttp tool does not support this URL scheme, please use aria2 or other tools for magnet/ed2k links" )
74+ }
7275 err = tryPutUrl (ctx , args .DstDirPath , args .URL )
7376 if err == nil || ! errors .Is (err , errs .NotImplement ) {
7477 return nil , err
7578 }
76- // SimpleHttp 不支持非 HTTP/HTTPS 协议(如 magnet、ed2k 等)
77- // tryPutUrl 返回 NotImplement 说明 URL 不是 HTTP/HTTPS
78- return nil , fmt .Errorf ("SimpleHttp tool does not support this URL scheme, please use aria2 or other tools for magnet/ed2k links" )
79+ // Fallback to creating a download task when storage lacks native PutURL support.
7980 }
8081
8182 // ed2k 链接自动路由:如果当前工具不支持 ed2k,自动尝试使用迅雷系工具
@@ -184,17 +185,22 @@ func tryPutUrl(ctx context.Context, path, urlStr string) error {
184185 var dstName string
185186 u , err := url .Parse (urlStr )
186187 if err == nil {
187- // 只支持 HTTP/HTTPS 协议,其他协议(magnet、ed2k 等)返回 NotImplement
188- if u .Scheme != "" && u .Scheme != "http" && u .Scheme != "https" {
189- return errors .WithStack (errs .NotImplement )
190- }
191188 dstName = stdpath .Base (u .Path )
192189 } else {
193190 dstName = "UnnamedURL"
194191 }
195192 return fs .PutURL (ctx , path , dstName , urlStr )
196193}
197194
195+ func isSimpleHttpSchemeUnsupported (urlStr string ) bool {
196+ u , err := url .Parse (strings .TrimSpace (urlStr ))
197+ if err != nil || u .Scheme == "" {
198+ return false
199+ }
200+ scheme := strings .ToLower (u .Scheme )
201+ return scheme != "http" && scheme != "https"
202+ }
203+
198204// isEd2kURL 检测 URL 是否为 ed2k 协议
199205func isEd2kURL (urlStr string ) bool {
200206 return strings .HasPrefix (strings .ToLower (urlStr ), "ed2k://" )
0 commit comments