10000 absolute_url in twig template missed path of request (only schema hostname asset-link) · Issue #32505 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
absolute_url in twig template missed path of request (only schema hostname asset-link) #32505
Closed
@patrickbussmann

Description

@patrickbussmann

Symfony version(s) affected: 4.3.2

Description

{{ absolute_url(asset('assets/images/header.png')) }}

results in

http://localhost/assets/images/header.png

But even the settings as the request url contains a path.

POST http://localhost/example/web/public/api/resetting/request

I expect something like:

http://localhost/example/web/public/assets/images/header.png

How to reproduce

	<?php
	
	use App\Kernel;
	use Symfony\Component\Dotenv\Dotenv;
	
	require_once __DIR__.'/vendor/autoload.php';
	
	if (!class_exists(Dotenv::class)) {
		throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
	}
	
	(new Dotenv())->load(__DIR__.'/.env');
	
	$kernel = new Kernel('dev', true);
	$kernel->boot();
	
	/** @var \Twig\Environment $twig */
	$twig = $kernel->getContainer()->get('twig');
	$template = $twig->createTemplate("{{ absolute_url(asset('assets/images/header.png')) }}");
	echo $template->render();
	
	/**
	 * Call script via: http://localhost/example/web/public/test.php
	 * Result: http://localhost/assets/images/header.png
	 * Expected: http://localhost/example/web/public/assets/images/header.png
	 */

Additional context
Related from the past:
#15448
#17503

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0