Skip to content

fix: let a link to an uploaded file open instead of routing to the index - #5071

Open
jamalkamaladdin wants to merge 1 commit into
flarum:2.xfrom
jamalkamaladdin:fix/issue-5012
Open

jamalkamaladdin wants to merge 1 commit into
flarum:2.xfrom
jamalkamaladdin:fix/issue-5012

Conversation

@jamalkamaladdin

Copy link
Copy Markdown

Fixes #5012.

Changes proposed in this pull request:

Formatter marks every same-host URL as an internal link, including one under the assets path. routeInternalLinks hands that path to Mithril, and Mithril has no route for a file path and returns to the index.
A click on such a link now checks whether its href starts with assetsBaseUrl, and a same prefix leaves the click to the browser. Changed file: framework/core/js/src/forum/utils/routeInternalLinks.ts.
New test: "leaves an uploaded file under the assets path to the browser", in framework/core/js/tests/unit/forum/utils/routeInternalLinks.test.ts.

Reviewers should focus on:

assetsBaseUrl can point at a host other than the forum's own, and the existing origin check returns before the new check runs in that case.

Screenshot

This is routing behavior with no visual change.

Necessity

  • Has the problem that is being solved here been clearly explained?
  • If applicable, have various options for solving this problem been considered?
  • For core PRs, does this need to be in core, or could it be in an extension?
  • Are we willing to maintain this for years / potentially forever?

Confirmed

  • Frontend changes: tested on a local Flarum installation.
  • Frontend changes: tests are green (run yarn test in js/).
  • Frontend changes: tests have been added, or are not appropriate here.
  • Backend changes: tests are green (run composer test).
  • Backend changes: tests have been added, or are not appropriate here.
  • Where applicable, changes are suitable for all supported database drivers (MySQL, MariaDB, PostgreSQL, SQLite).
  • Core developer confirmed locally this works as intended.
  • The description above is written by me and describes what this pull request actually does.

@jamalkamaladdin
jamalkamaladdin requested a review from a team as a code owner September 24, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clicking internal link to uploaded file redirects to home instead of opening it

1 participant