Skip to content

Commit

Permalink
Fix: st.page_link & st.switch_page handling / prefixed paths (#8085)
Browse files Browse the repository at this point in the history
Remove the convenience handling of preceding "/"
  • Loading branch information
mayagbarnes committed Feb 8, 2024
1 parent 9375977 commit 17ef7be
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions e2e_playwright/multipage_apps/pages/02_page2.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@

st.header("Page 2")

page_6 = st.button("`/pages/06_page_6.py`")
page_6 = st.button("`pages/06_page_6.py`")
if page_6:
st.switch_page("/pages/06_page_6.py")
st.switch_page("pages/06_page_6.py")
4 changes: 2 additions & 2 deletions lib/streamlit/commands/execution_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ def switch_page(page: str) -> NoReturn: # type: ignore[misc]
main_script_path = os.path.join(os.getcwd(), ctx.main_script_path)
main_script_directory = os.path.dirname(main_script_path)

# Convenience for handling ./ notation and ensure leading / doesn't refer to root directory
page = os.path.normpath(page.strip("/"))
# Convenience for handling ./ notation
page = os.path.normpath(page)

# Build full path
requested_page = os.path.join(main_script_directory, page)
Expand Down
4 changes: 2 additions & 2 deletions lib/streamlit/elements/widgets/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,8 @@ def _page_link(
main_script_path = os.path.join(os.getcwd(), ctx_main_script)
main_script_directory = os.path.dirname(main_script_path)

# Convenience for handling ./ notation and ensure leading / doesn't refer to root directory
page = os.path.normpath(page.strip("/"))
# Convenience for handling ./ notation
page = os.path.normpath(page)

# Build full path
requested_page = os.path.join(main_script_directory, page)
Expand Down

0 comments on commit 17ef7be

Please sign in to comment.