Skip to content

Commit cae9723

Browse files
committed
Fix url parsiing
Add goflagss to remove build path from stacktrace
1 parent 9d75cef commit cae9723

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

Makefile

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
GOCMD=go
2+
GOFLAGS=-o trace -gcflags "all=-trimpath=$GOPATH"
3+
14
all: clean darwin linux-386 linux-amd64 windows
25

36
clean:
@@ -7,19 +10,19 @@ clean:
710

811
darwin:
912
mkdir -p output
10-
GOOS=darwin GOARCH=amd64 go build -o ./build/darwin/MultiMC-Curseforge.app/Contents/MacOS/MultiMC-Curseforge
13+
GOOS=darwin GOARCH=amd64 $(GOCMD) build $(GOFLAGS) -o ./build/darwin/MultiMC-Curseforge.app/Contents/MacOS/MultiMC-Curseforge
1114
tar -czvf ./output/darwin.tar.gz --exclude .gitkeep -C ./build/darwin .
1215

1316
linux-386:
1417
mkdir -p output
15-
GOOS=linux GOARCH=386 go build -o ./build/linux/usr/bin/multimc-curseforge
18+
GOOS=linux GOARCH=386 $(GOCMD) build $(GOFLAGS) -o ./build/linux/usr/bin/multimc-curseforge
1619
tar -czvf ./output/linux-386.tar.gz --exclude .gitkeep -C ./build/linux .
1720

1821
linux-amd64:
1922
mkdir -p output
20-
GOOS=linux GOARCH=amd64 go build -o ./build/linux/usr/bin/multimc-curseforge
23+
GOOS=linux GOARCH=amd64 $(GOCMD) build $(GOFLAGS) -o ./build/linux/usr/bin/multimc-curseforge
2124
tar -czvf ./output/linux-amd64.tar.gz --exclude .gitkeep -C ./build/linux .
2225

2326
windows:
2427
mkdir -p output
25-
GOOS=windows GOARCH=386 go build -o ./output/MultiMC-Curseforge.exe
28+
GOOS=windows GOARCH=386 $(GOCMD) build $(GOFLAGS) -o ./output/MultiMC-Curseforge.exe
Binary file not shown.
88 Bytes
Binary file not shown.

main.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"os"
1010
"os/exec"
1111
"runtime"
12-
"strings"
1312
)
1413

1514
// Package - CCIP file structure
@@ -31,8 +30,7 @@ func main() {
3130

3231
url, err := url.ParseRequestURI(os.Args[1])
3332
if err == nil && url.Scheme == "curseforge" {
34-
paths := strings.Split(url.Path, "/")
35-
pack = GetPackURL(paths[3], paths[5])
33+
pack = GetPackURL(url.Query().Get("addonId"), url.Query().Get("fileId"))
3634
} else {
3735
pkg := LoadXML(os.Args[1])
3836
pack = GetPackURL(pkg.Project.ID, pkg.Project.File)
@@ -70,8 +68,8 @@ func LoadXML(fileName string) Package {
7068
}
7169

7270
// GetPackURL - Request the download url from Curseforge's API
73-
func GetPackURL(id string, file string) string {
74-
resp, err := http.Get("https://addons-ecs.forgesvc.net/api/v2/addon/" + id + "/file/" + file + "/download-url")
71+
func GetPackURL(addon string, file string) string {
72+
resp, err := http.Get("https://addons-ecs.forgesvc.net/api/v2/addon/" + addon + "/file/" + file + "/download-url")
7573
if err != nil {
7674
fmt.Println(err)
7775
os.Exit(1)

0 commit comments

Comments
 (0)