Commit 5b48ab88 authored by Bryan C. Mills's avatar Bryan C. Mills

cmd/go/internal/module: fix validation for module paths ending with /v

Unlike "/v1", "/v" is not likely to be mistaken for a semantic import path.

Change-Id: I024647d78c79c7761b98ddeccdc7e259ca94b568
Reviewed-on: https://go-review.googlesource.com/c/152738
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
parent 6ff8c1db
......@@ -284,7 +284,7 @@ func SplitPathVersion(path string) (prefix, pathMajor string, ok bool) {
}
i--
}
if i <= 1 || path[i-1] != 'v' || path[i-2] != '/' {
if i <= 1 || i == len(path) || path[i-1] != 'v' || path[i-2] != '/' {
return path, "", true
}
prefix, pathMajor = path[:i-2], path[i-2:]
......
......@@ -214,6 +214,7 @@ var splitPathVersionTests = []struct {
{"x.y/z", ""},
{"x.y/z", "/v2"},
{"x.y/z", "/v3"},
{"x.y/v", ""},
{"gopkg.in/yaml", ".v0"},
{"gopkg.in/yaml", ".v1"},
{"gopkg.in/yaml", ".v2"},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment