Do not alter absolute url

Created on 27 July 2023, over 1 year ago
Updated 31 July 2023, over 1 year ago

Problem/Motivation

Currently, the module skips prepending site's base url for resources like this one:
public://my-image.png

So all related paths are prepended but in case of an absolute url it makes it invalid.

Steps to reproduce

Install the twig_tweak module and try to create a similar my_component.stories.yml file:

title: my_theme/components/content/Media
stories:
  - name: 1. Default
    args:
      entity_id: 1
      entity_type: media
      view_mode: default
      langcode: ''
      check_access: true
      content: |
        {{ drupal_entity(entity_type, entity_id, view_mode, langcode, check_access) }}

And then for example test it in your storybook with an image media entity. You'd get an empty canvas because of img src attribute has base url prepended twice to the image path.

Proposed resolution

Check for absolute urls too, here:
https://git.drupalcode.org/project/cl_server/-/blob/2.x/cl_server.module...


  if ($route_name === 'cl_server.render' && !preg_match('%^(https?://|public://)%', $uri)) {
    $uri = implode('/', [$request->getSchemeAndHttpHost(), ltrim($uri, '/')]);
  }

Remaining tasks

?

User interface changes

?

API changes

?

Data model changes

📌 Task
Status

Fixed

Version

2.0

Component

Code

Created by

🇪🇪Estonia drugan

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

Comments & Activities

Production build 0.71.5 2024