Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: st.page_link & st.switch_page handling / prefixed paths #8085

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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