From 3bc0bb968836bb19389200e935b82670ea64d75d Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Thu, 7 Mar 2019 08:49:16 -0500 Subject: Getting _some_ integration tests running in appveyor (#507) * Running integration tests in appveyor Signed-off-by: Dave Henderson * fixup! Running integration tests in appveyor * fixup! fixup! Running integration tests in appveyor * fixup! fixup! fixup! Running integration tests in appveyor * fixup! fixup! fixup! fixup! Running integration tests in appveyor * fixup! fixup! fixup! fixup! fixup! Running integration tests in appveyor * fixup! fixup! fixup! fixup! fixup! fixup! Running integration tests in appveyor * fixup! fixup! fixup! fixup! fixup! fixup! fixup! Running integration tests in appveyor * fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! Running integration tests in appveyor * fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! Running integration tests in appveyor * fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! Running integration tests in appveyor * fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! Running integration tests in appveyor * fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! Running integration tests in appveyor * fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! Running integration tests in appveyor --- data/datasource.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'data/datasource.go') diff --git a/data/datasource.go b/data/datasource.go index 47ce6b81..b723aea8 100644 --- a/data/datasource.go +++ b/data/datasource.go @@ -10,6 +10,7 @@ import ( "os" "path" "path/filepath" + "regexp" "strings" "github.com/pkg/errors" @@ -210,15 +211,41 @@ func parseSource(value string) (source *Source, err error) { return source, nil } +func trimLeftChar(s string) string { + for i := range s { + if i > 0 { + return s[i:] + } + } + return s[:0] +} + func parseSourceURL(value string) (*url.URL, error) { if value == "-" { value = "stdin://" } + // handle absolute Windows paths + volName := "" + if volName = filepath.VolumeName(value); volName != "" { + // handle UNCs + if len(volName) > 2 { + value = "file:" + filepath.ToSlash(value) + } else { + value = "file:///" + filepath.ToSlash(value) + } + } srcURL, err := url.Parse(value) if err != nil { return nil, err } + if volName != "" { + p := regexp.MustCompile("^/[a-zA-Z]:.*$") + if p.MatchString(srcURL.Path) { + srcURL.Path = trimLeftChar(srcURL.Path) + } + } + if !srcURL.IsAbs() { srcURL, err = absURL(value) if err != nil { -- cgit v1.2.3