Skip to content

Commit

Permalink
Fix url parsiing
Browse files Browse the repository at this point in the history
Add goflagss to remove build path from stacktrace
  • Loading branch information
ShayBox committed Jan 10, 2021
1 parent 9d75cef commit cae9723
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
GOCMD=go
GOFLAGS=-o trace -gcflags "all=-trimpath=$GOPATH"

all: clean darwin linux-386 linux-amd64 windows

clean:
Expand All @@ -7,19 +10,19 @@ clean:

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

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

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

windows:
mkdir -p output
GOOS=windows GOARCH=386 go build -o ./output/MultiMC-Curseforge.exe
GOOS=windows GOARCH=386 $(GOCMD) build $(GOFLAGS) -o ./output/MultiMC-Curseforge.exe
Binary file not shown.
Binary file modified build/linux/usr/bin/multimc-curseforge
Binary file not shown.
8 changes: 3 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"os"
"os/exec"
"runtime"
"strings"
)

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

url, err := url.ParseRequestURI(os.Args[1])
if err == nil && url.Scheme == "curseforge" {
paths := strings.Split(url.Path, "/")
pack = GetPackURL(paths[3], paths[5])
pack = GetPackURL(url.Query().Get("addonId"), url.Query().Get("fileId"))
} else {
pkg := LoadXML(os.Args[1])
pack = GetPackURL(pkg.Project.ID, pkg.Project.File)
Expand Down Expand Up @@ -70,8 +68,8 @@ func LoadXML(fileName string) Package {
}

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

0 comments on commit cae9723

Please sign in to comment.