FIX: my links in sidebar section (#20754)

Links like `/my/preferences` were invalid in custom section. The reason is that `/my` links are just redirects from backend, and they are not recognized as valid Ember paths.

https://github.com/discourse/discourse/blob/main/config/routes.rb#L433

Therefore, regex match allowlist was added - similar to backend check:

https://github.com/discourse/discourse/blob/main/app/controllers/users_controller.rb#L471

/safe-mode is same case
This commit is contained in:
Krzysztof Kotlarek
2023-03-21 15:58:42 +11:00
committed by GitHub
parent ae939f4111
commit 1859025228
6 changed files with 48 additions and 5 deletions

View File

@ -34,6 +34,25 @@ describe "Custom sidebar sections", type: :system, js: true do
expect(sidebar).to have_link("Sidebar Tags")
end
it "allows the user to create custom section with /my link" do
visit("/latest")
sidebar.open_new_custom_section
expect(section_modal).to be_visible
expect(section_modal).to have_disabled_save
expect(sidebar.custom_section_modal_title).to have_content("Add custom section")
section_modal.fill_name("My section")
section_modal.fill_link("My preferences", "/my/preferences")
expect(section_modal).to have_enabled_save
section_modal.save
expect(page).to have_button("My section")
expect(sidebar).to have_link("My preferences")
end
it "allows the user to create custom section with external link" do
visit("/latest")
sidebar.open_new_custom_section