the universal sandbox runtime for agents and humans.
pocketenv.io
sandbox
openclaw
agent
claude-code
vercel-sandbox
deno-sandbox
cloudflare-sandbox
atproto
sprites
daytona
1export default function parseImageRef(ref: string): {
2 registry?: string;
3 name: string;
4 tag: string;
5} {
6 const tagSeparatorIndex = ref.lastIndexOf(":");
7 const slashBeforeTag = ref.lastIndexOf("/");
8
9 const hasTag = tagSeparatorIndex > slashBeforeTag;
10
11 const imageWithoutTag = hasTag ? ref.slice(0, tagSeparatorIndex) : ref;
12 const tag = hasTag ? ref.slice(tagSeparatorIndex + 1) : "latest";
13
14 const parts = imageWithoutTag.split("/");
15
16 const isRegistry = (s: string) => s.includes(".") || s.includes(":");
17 const registry = isRegistry(parts[0]!) ? parts[0] : "";
18 const name = isRegistry(parts[0]!)
19 ? parts.slice(1).join("/")
20 : parts.join("/");
21
22 return { registry, name, tag };
23}