Commit 1b060b1f authored by Michelle Noorali's avatar Michelle Noorali

Merge pull request #785 from migmartri/784-malformed

Fixed URL parse
parents 759f754f a0c1125a
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net/url"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
...@@ -131,9 +132,10 @@ func (r *ChartRepository) Index() error { ...@@ -131,9 +132,10 @@ func (r *ChartRepository) Index() error {
created = time.Now().UTC().String() created = time.Now().UTC().String()
} }
url := filepath.Join(r.URL, key+".tgz") url, _ := url.Parse(r.URL)
url.Path = filepath.Join(url.Path, key+".tgz")
entry := &ChartRef{Chartfile: *chartfile, Name: chartfile.Name, URL: url, Created: created, Checksum: hash, Removed: false} entry := &ChartRef{Chartfile: *chartfile, Name: chartfile.Name, URL: url.String(), Created: created, Checksum: hash, Removed: false}
r.IndexFile.Entries[key] = entry r.IndexFile.Entries[key] = entry
......
...@@ -90,7 +90,8 @@ func TestIndex(t *testing.T) { ...@@ -90,7 +90,8 @@ func TestIndex(t *testing.T) {
if v.Created != created { if v.Created != created {
t.Errorf("Expected Created timestamp to be %s, but got %s for chart %s", created, v.Created, chart) t.Errorf("Expected Created timestamp to be %s, but got %s for chart %s", created, v.Created, chart)
} }
expectedURL := filepath.Join(cr.URL, chart+".tgz") // Created manually since we control the input of the test
expectedURL := testURL + "/" + chart + ".tgz"
if v.URL != expectedURL { if v.URL != expectedURL {
t.Errorf("Expected url in entry to be %s but got %s for chart: %s", expectedURL, v.URL, chart) t.Errorf("Expected url in entry to be %s but got %s for chart: %s", expectedURL, v.URL, chart)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment