versionsapi: fix shortPath implementation

Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
This commit is contained in:
Paul Meyer 2023-01-05 16:55:57 +01:00
parent 6dad94137b
commit f17b40b44a
2 changed files with 10 additions and 3 deletions

View File

@ -320,12 +320,14 @@ var (
func shortPath(ref, stream, version string) string { func shortPath(ref, stream, version string) string {
var sp string var sp string
if ref != ReleaseRef { if ref != ReleaseRef {
sp = path.Join("ref", ref) return path.Join("ref", ref, "stream", stream, version)
} }
if stream != "stable" { if stream != "stable" {
sp = path.Join(sp, "stream", stream) return path.Join(sp, "stream", stream, version)
} }
return path.Join(sp, version)
return version
} }
func parseShortPath(shortPath string) (ref, stream, version string, err error) { func parseShortPath(shortPath string) (ref, stream, version string, err error) {

View File

@ -607,6 +607,11 @@ func TestShortPath(t *testing.T) {
stream: "debug", stream: "debug",
version: "v9.9.9", version: "v9.9.9",
}, },
"ref/foo/stream/stable/v9.9.9": {
ref: "foo",
stream: "stable",
version: "v9.9.9",
},
} }
for name, tc := range testCases { for name, tc := range testCases {