Skip to content

Commit 23fb61a

Browse files
committed
fix: rollback change with comment
1 parent 18be2b4 commit 23fb61a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/dependency-tree/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ export function nameAndVersionFromTargetImage(targetImage: string): {
99
let imageName: string;
1010
let imageVersion: string;
1111

12-
const finalSlash = targetImage.lastIndexOf("/");
13-
if (finalSlash >= 0 && targetImage.slice(finalSlash).includes(".tar")) {
12+
// TODO: this logic is not sufficient for OCI image references that end
13+
// in .tar (e.g. image:version.tar), which is a valid image name.
14+
// Additionally, the fallback parsing does not fully capture the information
15+
// availble in a valid archive name.
16+
// ref: https://github.com/containers/container-libs/blob/main/image/docs/containers-transports.5.md#containers-storagestorage-specifierimage-iddocker-referenceimage-id
17+
if (!targetImage.endsWith(".tar")) {
1418
try {
1519
const parsed = parseImageReference(targetImage);
1620
return {
@@ -26,6 +30,7 @@ export function nameAndVersionFromTargetImage(targetImage: string): {
2630
// check any colon separator after the final '/'. If there are no '/',
2731
// which is common when using Docker's official images such as
2832
// "debian:stretch", just check for ':'
33+
const finalSlash = targetImage.lastIndexOf("/");
2934
const hasVersion =
3035
(finalSlash >= 0 && targetImage.slice(finalSlash).includes(":")) ||
3136
targetImage.includes(":");

0 commit comments

Comments
 (0)