Fix base prefix when generating URLs if index.php is in the path

Created on 10 December 2019, about 5 years ago
Updated 22 June 2024, 6 months ago

Problem/Motivation

Follow-up to ✨ Introduce a token to get site's base URL Fixed

Steps to reproduce:

  1. Go to your installed drupal directory and append index.php (e.g http://drupal.test/index.php)
  2. Build a URL with base prefix: Url::fromUri('base:sites/default/files/og_image.jpg')
  3. Assert the URL to the image asset is broken as the path is /index.php/sites/default/files/og_image.jpg

Proposed resolution

When building a URL with base prefix use $request->getBasePath() instead of $request->getBaseUrl() which results in omitting index.php in case it is present.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Closed: duplicate

Version

11.0 πŸ”₯

Component
RoutingΒ  β†’

Last updated 3 days ago

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024