Skip to content

Commit

Permalink
Merge pull request hashicorp#78 from hashicorp/jbardin/escaped-path
Browse files Browse the repository at this point in the history
don't escape subdirs in Detect
  • Loading branch information
mitchellh authored Sep 5, 2017
2 parents 3942d21 + 6ac06b0 commit ee320ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,18 @@ func Detect(src string, pwd string, ds []Detector) (string, error) {
subDir = detectSubdir
}
}

if subDir != "" {
u, err := url.Parse(result)
if err != nil {
return "", fmt.Errorf("Error parsing URL: %s", err)
}
u.Path += "//" + subDir

// a subdir may contain wildcards, but in order to support them we
// have to ensure the path isn't escaped.
u.RawPath = u.Path

result = u.String()
}

Expand Down
6 changes: 6 additions & 0 deletions detect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ func TestDetect(t *testing.T) {
"git::https://github.com/hashicorp/consul.git",
false,
},
{
"./foo/archive//*",
"/bar",
"file:///bar/foo/archive//*",
false,
},
}

for i, tc := range cases {
Expand Down

0 comments on commit ee320ee

Please sign in to comment.