Skip to content

Commit 18be2b4

Browse files
committed
fix: improve archive detection
This change ensures that images references in the form of 'image.tar:tag' will fallback to the previous manual parsing code, rather than attempt to parse the string as an OCI image reference.
1 parent ab687c1 commit 18be2b4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/dependency-tree/index.ts

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

12-
if (!targetImage.endsWith(".tar")) {
12+
const finalSlash = targetImage.lastIndexOf("/");
13+
if (finalSlash >= 0 && targetImage.slice(finalSlash).includes(".tar")) {
1314
try {
1415
const parsed = parseImageReference(targetImage);
1516
return {
@@ -25,7 +26,6 @@ export function nameAndVersionFromTargetImage(targetImage: string): {
2526
// check any colon separator after the final '/'. If there are no '/',
2627
// which is common when using Docker's official images such as
2728
// "debian:stretch", just check for ':'
28-
const finalSlash = targetImage.lastIndexOf("/");
2929
const hasVersion =
3030
(finalSlash >= 0 && targetImage.slice(finalSlash).includes(":")) ||
3131
targetImage.includes(":");

0 commit comments

Comments
 (0)