Skip to content
This repository was archived by the owner on Jun 7, 2024. It is now read-only.

Commit f84d9d1

Browse files
committed
[get] fix signle file download
1 parent 1437e06 commit f84d9d1

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

fgit.go

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -248,31 +248,29 @@ func downloadFile(url, fpath string) {
248248
}
249249
}
250250

251+
startDown:
251252
if strings.HasPrefix(url, "https://github.com") {
252253
query := strings.Replace(url, "https://github.com", "", -1)
253254
querySplit := strings.Split(query, "/")
254-
if len(querySplit) <= 3 {
255-
goto startDown
256-
}
257-
// Source -> fastgitorg/fgit-go/blob/master/fgit.go
258-
// Target -> fastgitorg/fgit-go/master/fgit.go
259-
if querySplit[2] == "blob" {
260-
url = "https://raw.fastgit.org/"
261-
for _i, _s := range querySplit {
262-
if _i != 2 {
263-
// not /blob/
264-
if _i == len(querySplit)-1 {
265-
url += _s
266-
} else {
267-
url += _s + "/"
255+
if len(querySplit) > 3 {
256+
// Source -> fastgitorg/fgit-go/blob/master/fgit.go
257+
// Target -> fastgitorg/fgit-go/master/fgit.go
258+
if querySplit[3] == "blob" {
259+
url = "https://raw.fastgit.org/"
260+
for _i, _s := range querySplit {
261+
if _i != 3 {
262+
// not /blob/
263+
if _i == len(querySplit)-1 {
264+
url += _s
265+
} else {
266+
url += _s + "/"
267+
}
268268
}
269269
}
270+
fmt.Println("Redirect ->", url)
270271
}
271-
fmt.Println("Redirect ->", url)
272272
}
273273
}
274-
275-
startDown:
276274
newUrl := strings.Replace(url, "https://github.com", "https://download.fastgit.org", -1)
277275
if newUrl != url {
278276
fmt.Println("Redirect ->", newUrl)

0 commit comments

Comments
 (0)