From b0e2bcf22ede9c47d465f4a6e0b99f6080f7a49b Mon Sep 17 00:00:00 2001 From: Sneha P Pratap <170080122+snehaapratap@users.noreply.github.com> Date: Sat, 14 Nov 2026 10:16:30 +0530 Subject: [PATCH] util: Preserve registry ports when splitting image names --- nextstrain/cli/util.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/nextstrain/cli/util.py b/nextstrain/cli/util.py index eae7b27c..82dae17c 100644 --- a/nextstrain/cli/util.py +++ b/nextstrain/cli/util.py @@ -634,9 +634,24 @@ def split_image_name(name: str, implicit_latest: bool = True) -> Tuple[str, Opti >>> split_image_name("nextstrain/base:latest", implicit_latest = False) ('nextstrain/base', 'latest') + >>> split_image_name("localhost:5000/nextstrain/base:latest") + ('localhost:5000/nextstrain/base', 'latest') + + >>> split_image_name("localhost:5000/nextstrain/base") + ('localhost:5000/nextstrain/base', 'latest') + + >>> split_image_name("localhost:5000/nextstrain/base", implicit_latest = False) + ('localhost:5000/nextstrain/base', None) + + >>> split_image_name("[::1]:5000/nextstrain/base:build-20200424T101900Z") + ('[::1]:5000/nextstrain/base', 'build-20200424T101900Z') + + >>> split_image_name("[::1]:5000/nextstrain/base", implicit_latest = False) + ('[::1]:5000/nextstrain/base', None) + """ - if ":" in name: - repository, tag = name.split(":", maxsplit = 2) + if ":" in name.rsplit("/", maxsplit = 1)[-1]: + repository, tag = name.rsplit(":", maxsplit = 1) else: repository, tag = name, "latest" if implicit_latest else None