adding jupyterlab file paths for preview
@@ -61,6 +61,12 @@ class ParameterizedMainHandler(BaseHandler):
org, repo_name, ref = spec.split('/', 2)
# NOTE: tornado unquotes query arguments too -> notebooks%2Findex.ipynb becomes notebooks/index.ipynb
filepath = self.get_argument('filepath', '').lstrip('/')
+
+ # Check if we have a JupyterLab + file path, if so then use it for the filepath
+ urlpath = self.get_argument('urlpath', '').lstrip('/')
+ if 'lab/tree/' in urlpath:
+ filepath = urlpath.split('lab/tree/')[-1]
+
blob_or_tree = 'blob' if filepath else 'tree'
nbviewer_url = f'{nbviewer_url}/{org}/{repo_name}/{blob_or_tree}/{ref}/{filepath}'
self.render_template(
