Fix flag SVG 404 by resolving asset bundle base URL alias - #58
Merged
Conversation
luke-
force-pushed
the
fix/flag-asset-url-alias
branch
from
June 16, 2026 18:38
9a8152e to
8514cad
Compare
The team badge built the flag URL by concatenating the published asset bundle's baseUrl straight into the <img src>. That baseUrl is not guaranteed to be a final URL: HumHub develop's filesystem-backed asset manager sets it to the unresolved path alias `@web/assets/<hash>` and only resolves the alias when it emits <link>/<script> tags (Html::cssFile()/ Html::jsFile() run the URL through Url::to()). The hand-built <img src> bypassed that, so the literal `@web/...` was emitted and the browser resolved it against the current page URL (`…/kickoff/c/@web/assets/…`), 404ing the flag. Registered CSS was unaffected because it goes through Html::cssFile()→Url::to(). Resolve the flag URL through Url::to(), mirroring HumHub's own asset-URL handling (no-op for the already-resolved `/assets/<hash>` form on stable). Extracted into Assets::flagUrl() and covered by a unit test.
luke-
force-pushed
the
fix/flag-asset-url-alias
branch
from
June 16, 2026 21:07
8514cad to
7c35787
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Bundled team flag SVGs 404 on HumHub
develop, e.g.…/kickoff/c/@web/assets/<hash>/flags/1f1f2-1f1fd.svg— note the literal@webin the path.Cause
views/competition/_team_badge.phpbuilt the flag URL by concatenating the published asset bundle'sbaseUrlstraight into the<img src>:A bundle's
baseUrlis not guaranteed to be a final URL. HumHub develop's new filesystem-backedAssetManagersets the base URL from the assets mount config without resolving aliases ($this->baseUrl = Yii::$app->fs->getAssetsMountConfig()->getBaseUrl()), so it is the literal path alias@web/assets/<hash>. HumHub resolves that alias only when it emits<link>/<script>tags —Html::cssFile()/Html::jsFile()run the URL throughUrl::to(). The hand-built<img src>skipped that step, so the literal@web/...ended up in the markup and the browser resolved it relative to the current page (…/kickoff/c/@web/assets/…) → 404. Registered CSS was unaffected for exactly this reason. On stable it happened to work because the older asset manager resolvedbaseUrlat init.Note:
AssetManager::getAssetUrl($bundle, 'flags/x.svg')would not fix this — it returns$bundle->baseUrl . '/' . $assetand isn't overridden on develop, so it yields the same unresolved@web/....Fix
Resolve the flag URL through
Url::to(), mirroring HumHub's own asset-URL handling (Html::cssFile()→Url::to()). Extracted intoAssets::flagUrl(). This is a no-op for the already-resolved/assets/<hash>form on stable, so it is fully backwards-compatible, and also handles absolute base URLs (console/cron render) and the app-at-root case (@web='').Added
AssetsTestcovering the unresolved-alias and already-resolved cases.CI didn't catch this because no test renders the badge.