cue/load: fix test breakage for Windows
`:` can be used in file names in volume separators of paths. Only allow this is the value after `:` is a valid identifier.
Closes #256
https://github.com/cuelang/cue/pull/256
GitOrigin-RevId: 6a426d2a4ff9d697baf21306d1f022c017d78608
Change-Id: I2087878b3b6f77704ba38b0813631b57ba620d02
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/4580
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cue/load/loader.go b/cue/load/loader.go
index 54fa070..39e42b7 100644
--- a/cue/load/loader.go
+++ b/cue/load/loader.go
@@ -25,6 +25,7 @@
"strings"
"unicode"
+ "cuelang.org/go/cue/ast"
"cuelang.org/go/cue/build"
"cuelang.org/go/cue/encoding"
"cuelang.org/go/cue/errors"
@@ -51,7 +52,11 @@
// TODO: this is work in progress. We aim to replace the original Go
// implementation, which is not ideal for CUE.
if len(args) > 0 {
- arg := strings.Split(args[0], ":")[0]
+ arg := args[0]
+ p := strings.LastIndexByte(arg, ':')
+ if p >= 0 && ast.IsValidIdent(arg[p+1:]) {
+ arg = arg[:p]
+ }
if arg == "-" || encoding.MapExtension(filepath.Ext(arg)) != nil {
return []*build.Instance{l.cueFilesPackage(args)}
}