Skip to content

Commit

Permalink
fix: torrent file path resolve (GopeedLab#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyWie authored Aug 1, 2023
1 parent a75bfd6 commit bf2ccdb
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ This project is divided into two parts, the front end uses `flutter`, the back e
### Environment

1. Golang 1.19+
2. Flutter 3.7+
2. Flutter 3.10+

### Clone

Expand Down
2 changes: 1 addition & 1 deletion README_ja-JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ docker コンテナが起動しているときは、`http://localhost:9999` か
### 環境

1. Go 言語 1.19+
2. Flutter 3.7+
2. Flutter 3.10+

### クローン

Expand Down
2 changes: 1 addition & 1 deletion README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ docker-compose up -d
### 环境要求

1. Golang 1.19+
2. Flutter 3.7+
2. Flutter 3.10+

### 克隆项目

Expand Down
9 changes: 3 additions & 6 deletions pkg/util/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ const FileSchema = "FILE"

func ParseSchema(url string) string {
index := strings.Index(url, ":")
if index == -1 {
// check is file path
if IsExistsFile(url) {
return FileSchema
}
return ""
// if no schema or windows path like C:\a.txt, return FILE
if index == -1 || index == 1 {
return FileSchema
}
schema := url[:index]
if schema == "data" {
Expand Down
14 changes: 7 additions & 7 deletions pkg/util/url_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ func TestParseSchema(t *testing.T) {
},
want: "FILE",
},
{
name: "file-not-exists",
args: args{
url: "not.txt",
},
want: "",
},
{
name: "file-no-scheme",
args: args{
Expand All @@ -57,6 +50,13 @@ func TestParseSchema(t *testing.T) {
},
want: "APPLICATION/X-BITTORRENT",
},
{
name: "windows-path",
args: args{
url: "D:\\bt.torrent",
},
want: "FILE",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit bf2ccdb

Please sign in to comment.