Skip to content

Commit 65b06aa

Browse files
authored
make 'cwd' param for TerminalManager absolute (#749)
1 parent 3eaea4b commit 65b06aa

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

jupyter_server/terminal/api_handlers.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import os
23

34
from tornado import web
45

@@ -26,6 +27,15 @@ def post(self):
2627
"""POST /terminals creates a new terminal and redirects to it"""
2728
data = self.get_json_body() or {}
2829

30+
# if cwd is a relative path, it should be relative to the root_dir,
31+
# but if we pass it as relative, it will we be considered as relative to
32+
# the path jupyter_server was started in
33+
if "cwd" in data.keys():
34+
if not os.path.isabs(data["cwd"]):
35+
cwd = data["cwd"]
36+
cwd = os.path.join(self.settings["server_root_dir"], cwd)
37+
data["cwd"] = cwd
38+
2939
model = self.terminal_manager.create(**data)
3040
self.finish(json.dumps(model))
3141

0 commit comments

Comments
 (0)