From 3f0238719c39ca2778d7443c4e235db073b99f1f Mon Sep 17 00:00:00 2001 From: Victor Vrantchan Date: Mon, 30 Oct 2017 18:04:08 -0400 Subject: [PATCH] correctly encode the pkgurl in the manifest (#287) Closes #286 --- cmd/mdmctl/apply_app.go | 5 ++++- cmd/mdmctl/apply_app_test.go | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 cmd/mdmctl/apply_app_test.go diff --git a/cmd/mdmctl/apply_app.go b/cmd/mdmctl/apply_app.go index d85002c1..8683de9d 100644 --- a/cmd/mdmctl/apply_app.go +++ b/cmd/mdmctl/apply_app.go @@ -169,7 +169,10 @@ func (cmd *applyCommand) serverRepoURL() (string, error) { } func pkgURL(repoURL, pkgPath string) string { - return path.Join(repoURL, filepath.Base(pkgPath)) + u, _ := url.Parse(repoURL) + newPath := path.Join(u.Path, filepath.Base(pkgPath)) + u.Path = newPath + return u.String() } func repoURL(server string) (string, error) { diff --git a/cmd/mdmctl/apply_app_test.go b/cmd/mdmctl/apply_app_test.go new file mode 100644 index 00000000..ab2b09c0 --- /dev/null +++ b/cmd/mdmctl/apply_app_test.go @@ -0,0 +1,15 @@ +package main + +import ( + "testing" +) + +func TestPkgURL(t *testing.T) { + baseURL := "https://mdm.acme.co/repo" + pkgPath := "/Users/user/Desktop/dep_pkg-foo_1.1.pkg" + u := pkgURL(baseURL, pkgPath) + if have, want := u, "https://mdm.acme.co/repo/dep_pkg-foo_1.1.pkg"; have != want { + t.Errorf("have %s, want %s", have, want) + } + +}