Skip to content

Commit

Permalink
add slash to channel urls during replacement in case input had slashe…
Browse files Browse the repository at this point in the history
…s too
  • Loading branch information
jaimergp committed Dec 3, 2024
1 parent b14f855 commit b8c95a9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions constructor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -186,7 +191,6 @@ def get_final_url(info, url):
srcs = tuple(
dict.fromkeys(
[
src,
src.replace("http://", "https://"),
src.replace("https://", "http://")
]
Expand All @@ -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

Expand Down

0 comments on commit b8c95a9

Please sign in to comment.