Skip to content

Commit

Permalink
Normalize main script path in st.switch_page and st.page_link (st…
Browse files Browse the repository at this point in the history
  • Loading branch information
kajarenc authored and zyxue committed Apr 16, 2024
1 parent 61c1502 commit 5e121ce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/streamlit/commands/execution_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ def switch_page(page: str) -> NoReturn: # type: ignore[misc]
# This should never be the case
raise NoSessionContext()

main_script_path = os.path.join(os.getcwd(), ctx.main_script_path)
normalized_ctx_main_script_path = os.path.normpath(ctx.main_script_path)
main_script_path = os.path.join(os.getcwd(), normalized_ctx_main_script_path)
main_script_directory = os.path.dirname(main_script_path)

# Convenience for handling ./ notation
Expand Down
3 changes: 2 additions & 1 deletion lib/streamlit/elements/widgets/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,8 @@ def _page_link(
if ctx:
ctx_main_script = ctx.main_script_path

main_script_path = os.path.join(os.getcwd(), ctx_main_script)
normalized_ctx_main_script_path = os.path.normpath(ctx_main_script)
main_script_path = os.path.join(os.getcwd(), normalized_ctx_main_script_path)
main_script_directory = os.path.dirname(main_script_path)

# Convenience for handling ./ notation
Expand Down

0 comments on commit 5e121ce

Please sign in to comment.