#110016typolink forceAbsoluteUrl returns ":///path" for file and path links
Description
Since TYPO3 v14, `typolink.forceAbsoluteUrl = 1` produces broken URLs like `:///path/to/file.jpg` (empty scheme and host) for links whose target is a file or a root-relative path — e.g. URLs coming from `IMG_RESOURCE`.
Reproduce
Minimal TypoScript on any TYPO3 v14 site (default site configuration, no special `config.` settings required):
page.10 = TEXT
page.10.typolink {
parameter.cObject = IMG_RESOURCE
parameter.cObject.file = EXT:my_sitepackage/Resources/Public/Images/example.jpg
returnLast = url
forceAbsoluteUrl = 1
}
Or this example here https://forge.typo3.org/issues/101709
### Expected result
https://example.org/_assets/hash/Images/example.jpg
### Actual result
:///_assets/hash/Images/example.jpg
### Analysis
Seems the regression was introduced in commit
(“[!!!][FEATURE] Add TypolinkBuilderInterface with automatic DI”, https://review.typo3.org/c/Packages/TYPO3.CMS/+/86036).
In `AbstractTypolinkBuilder::forceAbsoluteUrl()`, the assignment of scheme
and host was accidentally moved inside the
`FrontendUrlPrefix->getUrlPrefix($request) === ‘’` condition:
// v14 (broken):
if (empty($urlParts[‘host’])) {
if (GeneralUtility::makeInstance(FrontendUrlPrefix::class)->getUrlPrefix($request) === ‘’) {
// scheme, host and path are only set here …
}
$isUrlModified = true; // … but the URL is re-assembled anyway
}
In v13 the equivalent code always set scheme and host; only the
site-path prepending was conditional on `absRefPrefix`:
// v13 (working):
if (empty($urlParts[‘host’])) {
$urlParts[‘scheme’] = $normalizedParams->isHttps() ? ‘https’ : ‘http’;
$urlParts[‘host’] = $normalizedParams->getHttpHost();
$urlParts[‘path’] = ‘/’ . ltrim($urlParts[‘path’], ‘/’);
// absRefPrefix has been prepended to $url beforehand
// so we only modify the path if no absRefPrefix has been set
if ($this->getTypoScriptFrontendController()->absRefPrefix === ‘’) {
$urlParts[‘path’] = $normalizedParams->getSitePath() . ltrim($urlParts[‘path’], ‘/’);
}
$isUrlModified = true;
}
Because `$isUrlModified` is still set to `true`, the URL is re-assembled
from the parts array (`scheme . ‘://’ . host . path`) with empty scheme
and host, resulting in `:///path`.