refactor: make parseImageName more readable (#228)

This commit is contained in:
Brandon Keiji 2025-04-30 17:16:29 +00:00 committed by GitHub
parent 3ec00d1689
commit 3aef883f4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 6 deletions

View File

@ -41,13 +41,12 @@ export function sandbox_command(): string {
}
}
// docker does not allow container names to contain ':' or '/', so we
// parse those out and make the name a little shorter
function parseImageName(image: string): string {
const parts = image.split(':');
const uri = parts[0];
const uriParts = uri.split('/');
const name = uriParts.at(-1);
const tag = parts.length > 1 ? `-${parts[1]}` : '';
return `${name}${tag}`;
const [fullName, tag] = image.split(':');
const name = fullName.split('/').at(-1) ?? 'unknown-image';
return tag ? `${name}-${tag}` : name;
}
// node.js equivalent of scripts/start_sandbox.sh