From 12c8cc5875f1a2eb664e01cbc05c9dd7789635cf Mon Sep 17 00:00:00 2001 From: Brandon Squizzato <35474886+bsquizz@users.noreply.github.com> Date: Thu, 2 Sep 2021 16:04:27 -0400 Subject: [PATCH] Handle trailing slash in template url (#108) --- bonfire/qontract.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bonfire/qontract.py b/bonfire/qontract.py index 2baa872a..09fbfa02 100644 --- a/bonfire/qontract.py +++ b/bonfire/qontract.py @@ -1,6 +1,7 @@ import json import copy import logging +from urllib.parse import urlparse from gql import gql from gql import Client as GQLClient @@ -227,7 +228,11 @@ def _add_component(apps, env, app_name, saas_file, resource_template, target, de ) host = "github" if "github" in url else "gitlab" - org, repo = url.split("/")[-2:] + try: + parsed_url = urlparse(url) + org, repo = parsed_url.path.rstrip("/").split("/")[-2:] + except (ValueError, IndexError) as err: + raise ValueError(f"invalid repo url '{url}': {err}") # merge the various layers of parameters p = copy.deepcopy(_to_dict(env["parameters"]))