aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/go-getter/source.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/go-getter/source.go')
-rw-r--r--vendor/github.com/hashicorp/go-getter/source.go23
1 files changed, 18 insertions, 5 deletions
diff --git a/vendor/github.com/hashicorp/go-getter/source.go b/vendor/github.com/hashicorp/go-getter/source.go
index c63f2bb..dab6d40 100644
--- a/vendor/github.com/hashicorp/go-getter/source.go
+++ b/vendor/github.com/hashicorp/go-getter/source.go
@@ -6,18 +6,31 @@ import (
6 "strings" 6 "strings"
7) 7)
8 8
9// SourceDirSubdir takes a source and returns a tuple of the URL without 9// SourceDirSubdir takes a source URL and returns a tuple of the URL without
10// the subdir and the URL with the subdir. 10// the subdir and the subdir.
11//
12// ex:
13// dom.com/path/?q=p => dom.com/path/?q=p, ""
14// proto://dom.com/path//*?q=p => proto://dom.com/path?q=p, "*"
15// proto://dom.com/path//path2?q=p => proto://dom.com/path?q=p, "path2"
16//
11func SourceDirSubdir(src string) (string, string) { 17func SourceDirSubdir(src string) (string, string) {
12 // Calcaulate an offset to avoid accidentally marking the scheme 18
19 // URL might contains another url in query parameters
20 stop := len(src)
21 if idx := strings.Index(src, "?"); idx > -1 {
22 stop = idx
23 }
24
25 // Calculate an offset to avoid accidentally marking the scheme
13 // as the dir. 26 // as the dir.
14 var offset int 27 var offset int
15 if idx := strings.Index(src, "://"); idx > -1 { 28 if idx := strings.Index(src[:stop], "://"); idx > -1 {
16 offset = idx + 3 29 offset = idx + 3
17 } 30 }
18 31
19 // First see if we even have an explicit subdir 32 // First see if we even have an explicit subdir
20 idx := strings.Index(src[offset:], "//") 33 idx := strings.Index(src[offset:stop], "//")
21 if idx == -1 { 34 if idx == -1 {
22 return src, "" 35 return src, ""
23 } 36 }