correctly encode the pkgurl in the manifest (#287)

Closes #286
This commit is contained in:
Victor Vrantchan
2017-10-30 18:04:08 -04:00
committed by GitHub
parent 382b3d0cec
commit 3f0238719c
2 changed files with 19 additions and 1 deletions

View File

@@ -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) {

View File

@@ -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)
}
}