From 2fb503df179bdadf4d30dd51bb05d074adb7ab45 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Mon, 27 Feb 2017 13:53:23 -0500 Subject: [PATCH] Ensure that SERVICE_FIX has trailing slash. Fixes Issue #997. Also updated Traitlets to 4.3.2 since the change in singleuser.py relies on trait default values being checked through validator, which was added in traitlets 4.3.2. --- jupyterhub/services/service.py | 2 +- jupyterhub/singleuser.py | 11 +++++++++++ requirements.txt | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/jupyterhub/services/service.py b/jupyterhub/services/service.py index 546c8c78..894d45af 100644 --- a/jupyterhub/services/service.py +++ b/jupyterhub/services/service.py @@ -204,7 +204,7 @@ class Service(LoggingConfigurable): @property def prefix(self): - return url_path_join(self.base_url, 'services', self.name) + return url_path_join(self.base_url, 'services', self.name + '/') @property def proxy_path(self): diff --git a/jupyterhub/singleuser.py b/jupyterhub/singleuser.py index 6366f700..65c69164 100755 --- a/jupyterhub/singleuser.py +++ b/jupyterhub/singleuser.py @@ -180,6 +180,17 @@ class SingleUserNotebookApp(NotebookApp): def _base_url_default(self): return os.environ.get('JUPYTERHUB_SERVICE_PREFIX') or '/' + #Note: this may be removed if notebook module is >= 5.0.0b1 + @validate('base_url') + def _validate_base_url(self, proposal): + """ensure base_url starts and ends with /""" + value = proposal.value + if not value.startswith('/'): + value = '/' + value + if not value.endswith('/'): + value = value + '/' + return value + @default('cookie_name') def _cookie_name_default(self): if os.environ.get('JUPYTERHUB_SERVICE_NAME'): diff --git a/requirements.txt b/requirements.txt index 82528a48..7271e737 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ alembic -traitlets>=4.3 +traitlets>=4.3.2 tornado>=4.1 jinja2 pamela