summaryrefslogtreecommitdiff
path: root/data/datasource.go
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2019-03-07 08:49:16 -0500
committerGitHub <noreply@github.com>2019-03-07 08:49:16 -0500
commit3bc0bb968836bb19389200e935b82670ea64d75d (patch)
tree5b7d57fbb9b6e7b8f2f2ec6ebca676837a07d17d /data/datasource.go
parent5c27e1ee5c1c37644af0a8e1db89c34c58b1277f (diff)
Getting _some_ integration tests running in appveyor (#507)
* Running integration tests in appveyor Signed-off-by: Dave Henderson <dhenderson@gmail.com> * 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
Diffstat (limited to 'data/datasource.go')
-rw-r--r--data/datasource.go27
1 files changed, 27 insertions, 0 deletions
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 {