From 0a6f481ac9a99011f769313b6418bb23109ae205 Mon Sep 17 00:00:00 2001
From: Stefano Alberto Russo <stefano.russo@gmail.com>
Date: Wed, 6 Apr 2022 03:03:30 +0200
Subject: [PATCH] Bugfix of some strange behaviour of an https:// contained as
 part in the URL transformed into https:/.

---
 .../webapp/code/rosetta/core_app/views.py     | 24 +++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/services/webapp/code/rosetta/core_app/views.py b/services/webapp/code/rosetta/core_app/views.py
index 76540bd..68164b7 100644
--- a/services/webapp/code/rosetta/core_app/views.py
+++ b/services/webapp/code/rosetta/core_app/views.py
@@ -1218,7 +1218,15 @@ def new_binder_task(request, repository):
     # Set repository name/tag/url        
     repository_tag = repository.split('/')[-1]
     repository_url = repository.replace('/'+repository_tag, '')
+
+    # I have no idea why the https:// of the repo part of the url gets transfrmed in https:/
+    # Here i work around this, but TODO: understand what the hell is going on.
+    if 'https:/' in repository_url and not 'https://' in repository_url:
+        repository_url = repository_url.replace('https:/', 'https://')
     
+    if not repository_tag:
+        repository_tag='HEAD'
+
     data['repository_url'] = repository_url
     data['repository_tag'] = repository_tag
     
@@ -1240,10 +1248,18 @@ def import_repository(request):
     data={}
     data['user']  = request.user
     
-    data['repository_url'] = request.GET.get('repository_url', None)
-    data['repository_tag'] = request.GET.get('repository_tag', 'HEAD')
-    if not data['repository_tag']:
-        data['repository_tag']='HEAD'
+    repository_url = request.GET.get('repository_url', None)
+    # I have no idea why the https:// of the repo part of the url gets transfrmed in https:/
+    # Here i work around this, but TODO: understand what the hell is going on.
+    if 'https:/' in repository_url and not 'https://' in repository_url:
+        repository_url = repository_url.replace('https:/', 'https://')
+    
+    repository_tag= request.GET.get('repository_tag', None)
+    if not repository_tag:
+        repository_tag='HEAD'
+        
+    data['repository_url'] = repository_url
+    data['repository_tag'] = repository_tag
 
     data['container_name'] = request.GET.get('container_name', None)
     data['container_description'] = request.GET.get('container_description', None)
-- 
GitLab