diff options
| author | Brandon Keiji <[email protected]> | 2025-04-30 17:16:29 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-04-30 10:16:29 -0700 |
| commit | 3aef883f4b834d0e3bf58f214324c384f0865b41 (patch) | |
| tree | 90945e77d1fc8b8fd085f51ee844fd97c7586697 /packages/cli/src | |
| parent | 3ec00d1689019e113ea4dafe50647508433b6142 (diff) | |
refactor: make parseImageName more readable (#228)
Diffstat (limited to 'packages/cli/src')
| -rw-r--r-- | packages/cli/src/utils/sandbox.ts | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/packages/cli/src/utils/sandbox.ts b/packages/cli/src/utils/sandbox.ts index 828df469..77f42e4d 100644 --- a/packages/cli/src/utils/sandbox.ts +++ b/packages/cli/src/utils/sandbox.ts @@ -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 |
