From b8c95a933bafbdc3c0734f486e47f1fcd61b1cb9 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 3 Dec 2024 19:33:51 +0100 Subject: [PATCH] add slash to channel urls during replacement in case input had slashes too --- constructor/utils.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/constructor/utils.py b/constructor/utils.py index 277c2cead..4b2c6352a 100644 --- a/constructor/utils.py +++ b/constructor/utils.py @@ -178,6 +178,11 @@ def ensure_transmuted_ext(info, url): def get_final_url(info, url): mapping = info.get('channels_remap', []) + if not url.lower().endswith((".tar.bz2", ".conda", "/")): + url += "/" + added_slash = True + else: + added_slash = False for entry in mapping: src = entry['src'] dst = entry['dest'] @@ -186,7 +191,6 @@ def get_final_url(info, url): srcs = tuple( dict.fromkeys( [ - src, src.replace("http://", "https://"), src.replace("https://", "http://") ] @@ -195,11 +199,14 @@ def get_final_url(info, url): else: srcs = (src,) if url.startswith(srcs): + new_url = url for src in srcs: - new_url = url.replace(src, dst) + new_url = new_url.replace(src, dst) if url.endswith(".tar.bz2"): logger.warning("You need to make the package %s available " "at %s", url.rsplit('/', 1)[1], new_url) + if added_slash: + new_url = new_url[:-1] return new_url return url