Skip to content

Commit e162b9c

Browse files
authored
🐛 Show asset url when only one asset is scanned (#278)
Signed-off-by: Christian Zunker <christian@mondoo.com>
1 parent 8f9caa8 commit e162b9c

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

cli/reporter/print_compact.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,20 @@ func (r *defaultReporter) printSummary(orderedAssets []assetMrnName) {
150150
if r.isCompact {
151151
r.out.Write([]byte(NewLineCharacter))
152152
if !r.IsIncognito && assetUrl != "" {
153-
// we do not have a space url, so we extract it form the asset url
154-
// https://console.mondoo.com/space/fleet/2JtqGyVTZULTW0uwQ5YxXW4nh6Y?spaceId=dazzling-golick-767384
155-
// an individual asset url wouldn't make sense here
156-
spaceUrlRegexp := regexp.MustCompile(`^(http.*)/[a-zA-Z0-9-]+(\?.+)$`)
157-
m := spaceUrlRegexp.FindStringSubmatch(assetUrl)
158-
spaceUrl := m[1] + m[2]
153+
url := ""
154+
if len(orderedAssets) > 1 {
155+
// we do not have a space url, so we extract it form the asset url
156+
// https://console.mondoo.com/space/fleet/2JtqGyVTZULTW0uwQ5YxXW4nh6Y?spaceId=dazzling-golick-767384
157+
// an individual asset url wouldn't make sense here
158+
spaceUrlRegexp := regexp.MustCompile(`^(http.*)/[a-zA-Z0-9-]+(\?.+)$`)
159+
m := spaceUrlRegexp.FindStringSubmatch(assetUrl)
160+
url = m[1] + m[2]
161+
} else {
162+
url = assetUrl
163+
}
159164

160165
r.out.Write([]byte("Detailed information is already available via the web UI: "))
161-
r.out.Write([]byte(spaceUrl + NewLineCharacter))
166+
r.out.Write([]byte(url + NewLineCharacter))
162167
}
163168
if len(assetsByScore) > 0 {
164169
r.out.Write([]byte("To get more information on the CLI, please run this scan with \"-o full\"." + NewLineCharacter))

0 commit comments

Comments
 (0)