Skip to content

Commit

Permalink
make 'cwd' param for TerminalManager absolute (#749)
Browse files Browse the repository at this point in the history
  • Loading branch information
rccern committed Mar 23, 2022
1 parent 3eaea4b commit 65b06aa
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions jupyter_server/terminal/api_handlers.py
@@ -1,4 +1,5 @@
import json
import os

from tornado import web

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

# if cwd is a relative path, it should be relative to the root_dir,
# but if we pass it as relative, it will we be considered as relative to
# the path jupyter_server was started in
if "cwd" in data.keys():
if not os.path.isabs(data["cwd"]):
cwd = data["cwd"]
cwd = os.path.join(self.settings["server_root_dir"], cwd)
data["cwd"] = cwd

model = self.terminal_manager.create(**data)
self.finish(json.dumps(model))

Expand Down

0 comments on commit 65b06aa

Please sign in to comment.