mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-07 17:10:29 +00:00
fix: torrent file path resolve (#173)
This commit is contained in:
5 files changed
+13
-16
No files matched your search
@@ -74,7 +74,7 @@ This project is divided into two parts, the front end uses `flutter`, the back e
|
|||||||
### Environment
|
### Environment
|
||||||
|
|
||||||
1. Golang 1.19+
|
1. Golang 1.19+
|
||||||
2. Flutter 3.7+
|
2. Flutter 3.10+
|
||||||
|
|
||||||
### Clone
|
### Clone
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -74,7 +74,7 @@ docker コンテナが起動しているときは、`http://localhost:9999` か
|
|||||||
### 環境
|
### 環境
|
||||||
|
|
||||||
1. Go 言語 1.19+
|
1. Go 言語 1.19+
|
||||||
2. Flutter 3.7+
|
2. Flutter 3.10+
|
||||||
|
|
||||||
### クローン
|
### クローン
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -74,7 +74,7 @@ docker-compose up -d
|
|||||||
### 环境要求
|
### 环境要求
|
||||||
|
|
||||||
1. Golang 1.19+
|
1. Golang 1.19+
|
||||||
2. Flutter 3.7+
|
2. Flutter 3.10+
|
||||||
|
|
||||||
### 克隆项目
|
### 克隆项目
|
||||||
|
|
||||||
|
|||||||
+3
-6
@@ -10,12 +10,9 @@ const FileSchema = "FILE"
|
|||||||
|
|
||||||
func ParseSchema(url string) string {
|
func ParseSchema(url string) string {
|
||||||
index := strings.Index(url, ":")
|
index := strings.Index(url, ":")
|
||||||
if index == -1 {
|
// if no schema or windows path like C:\a.txt, return FILE
|
||||||
// check is file path
|
if index == -1 || index == 1 {
|
||||||
if IsExistsFile(url) {
|
return FileSchema
|
||||||
return FileSchema
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
}
|
||||||
schema := url[:index]
|
schema := url[:index]
|
||||||
if schema == "data" {
|
if schema == "data" {
|
||||||
|
|||||||
@@ -36,13 +36,6 @@ func TestParseSchema(t *testing.T) {
|
|||||||
},
|
},
|
||||||
want: "FILE",
|
want: "FILE",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "file-not-exists",
|
|
||||||
args: args{
|
|
||||||
url: "not.txt",
|
|
||||||
},
|
|
||||||
want: "",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "file-no-scheme",
|
name: "file-no-scheme",
|
||||||
args: args{
|
args: args{
|
||||||
@@ -57,6 +50,13 @@ func TestParseSchema(t *testing.T) {
|
|||||||
},
|
},
|
||||||
want: "APPLICATION/X-BITTORRENT",
|
want: "APPLICATION/X-BITTORRENT",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "windows-path",
|
||||||
|
args: args{
|
||||||
|
url: "D:\\bt.torrent",
|
||||||
|
},
|
||||||
|
want: "FILE",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
|||||||
Reference in new issue
Block a user