diff --git a/nbgitpuller/handlers.py b/nbgitpuller/handlers.py index a88f3251..5f4746f3 100644 --- a/nbgitpuller/handlers.py +++ b/nbgitpuller/handlers.py @@ -132,6 +132,20 @@ def pull(): self.git_lock.release() +USED_UI_ARGUMENTS = frozenset(( + 'repo', + 'branch', + 'depth', + 'urlpath', + 'urlPath', + 'subpath', + 'subPath', + 'app', + 'targetpath', + 'targetPath', +)) + + class UIHandler(IPythonHandler): @web.authenticated async def get(self): @@ -149,6 +163,8 @@ async def get(self): targetpath = self.get_argument('targetpath', None) or \ self.get_argument('targetPath', repo.split('/')[-1]) + targetpath = self.combine_qs(targetpath) + if urlPath: path = urlPath else: @@ -168,6 +184,17 @@ async def get(self): ) await self.flush() + def combine_qs(self, targetpath): + from urllib.parse import urlparse, parse_qs, urlencode, urlunparse + target_parsed = urlparse(targetpath) + target_qs = parse_qs(target_parsed.query) + for key in self.request.arguments: + if key in USED_UI_ARGUMENTS or key in target_qs: + continue + target_qs[key] = self.get_argument(key) + targetpath = urlunparse(target_parsed._replace(query=urlencode(target_qs, doseq=True))) + return targetpath + class LegacyGitSyncRedirectHandler(IPythonHandler): """