generateAmpURL() provides wrong URL

Created on 30 January 2018, over 6 years ago
Updated 15 February 2023, over 1 year ago

While looking at my AMP page's normal source, the 'amphtml' tag should contain the proper URL. However, when I look at it I get something like this:

<link rel="amphtml" href="http://cmslocal.gfs.comhttp://cmslocal.gfs.com/en-us/about-us/news-and-events/recall-sunglow-unsalted-european-style-butter-blend/amp" />

As you can see the base_url is prepended twice. It looks like in the function that $path is already getting the correct URL so there's no need for base_url to be prepended.

Current code:

  public function generateAmpURL() {
    $path = Url::fromRoute('simple_amp.amp', ['entity' => $this->getEntity()->id()]);
    $base_url = \Drupal::request()->getSchemeAndHttpHost();
    return rtrim($base_url, '/') . $path->toString();
  }
πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

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.

No activities found.

Production build 0.69.0 2024