diff options
Diffstat (limited to 'vendor/github.com/hashicorp/go-getter/helper/url')
3 files changed, 65 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/go-getter/helper/url/url.go b/vendor/github.com/hashicorp/go-getter/helper/url/url.go new file mode 100644 index 0000000..02497c2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/helper/url/url.go | |||
@@ -0,0 +1,14 @@ | |||
1 | package url | ||
2 | |||
3 | import ( | ||
4 | "net/url" | ||
5 | ) | ||
6 | |||
7 | // Parse parses rawURL into a URL structure. | ||
8 | // The rawURL may be relative or absolute. | ||
9 | // | ||
10 | // Parse is a wrapper for the Go stdlib net/url Parse function, but returns | ||
11 | // Windows "safe" URLs on Windows platforms. | ||
12 | func Parse(rawURL string) (*url.URL, error) { | ||
13 | return parse(rawURL) | ||
14 | } | ||
diff --git a/vendor/github.com/hashicorp/go-getter/helper/url/url_unix.go b/vendor/github.com/hashicorp/go-getter/helper/url/url_unix.go new file mode 100644 index 0000000..ed1352a --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/helper/url/url_unix.go | |||
@@ -0,0 +1,11 @@ | |||
1 | // +build !windows | ||
2 | |||
3 | package url | ||
4 | |||
5 | import ( | ||
6 | "net/url" | ||
7 | ) | ||
8 | |||
9 | func parse(rawURL string) (*url.URL, error) { | ||
10 | return url.Parse(rawURL) | ||
11 | } | ||
diff --git a/vendor/github.com/hashicorp/go-getter/helper/url/url_windows.go b/vendor/github.com/hashicorp/go-getter/helper/url/url_windows.go new file mode 100644 index 0000000..4655226 --- /dev/null +++ b/vendor/github.com/hashicorp/go-getter/helper/url/url_windows.go | |||
@@ -0,0 +1,40 @@ | |||
1 | package url | ||
2 | |||
3 | import ( | ||
4 | "fmt" | ||
5 | "net/url" | ||
6 | "path/filepath" | ||
7 | "strings" | ||
8 | ) | ||
9 | |||
10 | func parse(rawURL string) (*url.URL, error) { | ||
11 | // Make sure we're using "/" since URLs are "/"-based. | ||
12 | rawURL = filepath.ToSlash(rawURL) | ||
13 | |||
14 | u, err := url.Parse(rawURL) | ||
15 | if err != nil { | ||
16 | return nil, err | ||
17 | } | ||
18 | |||
19 | if len(rawURL) > 1 && rawURL[1] == ':' { | ||
20 | // Assume we're dealing with a drive letter file path where the drive | ||
21 | // letter has been parsed into the URL Scheme, and the rest of the path | ||
22 | // has been parsed into the URL Path without the leading ':' character. | ||
23 | u.Path = fmt.Sprintf("%s:%s", string(rawURL[0]), u.Path) | ||
24 | u.Scheme = "" | ||
25 | } | ||
26 | |||
27 | if len(u.Host) > 1 && u.Host[1] == ':' && strings.HasPrefix(rawURL, "file://") { | ||
28 | // Assume we're dealing with a drive letter file path where the drive | ||
29 | // letter has been parsed into the URL Host. | ||
30 | u.Path = fmt.Sprintf("%s%s", u.Host, u.Path) | ||
31 | u.Host = "" | ||
32 | } | ||
33 | |||
34 | // Remove leading slash for absolute file paths. | ||
35 | if len(u.Path) > 2 && u.Path[0] == '/' && u.Path[2] == ':' { | ||
36 | u.Path = u.Path[1:] | ||
37 | } | ||
38 | |||
39 | return u, err | ||
40 | } | ||