Commit 9caa48f3 authored by catch's avatar catch
Browse files

Issue #3266589 by idebr, mfb, longwave: Remove redundant Link canonical/shortlink response headers

(cherry picked from commit 32153203)
parent e7b687af
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -147,7 +147,6 @@ public function view(EntityInterface $_entity, $view_mode = 'full') {
          'rel' => 'canonical',
          'href' => $url->toString(),
        ],
        TRUE,
      ];

      // Set the non-aliased canonical path as a default shortlink.
@@ -156,7 +155,6 @@ public function view(EntityInterface $_entity, $view_mode = 'full') {
          'rel' => 'shortlink',
          'href' => $url->setOption('alias', TRUE)->toString(),
        ],
        TRUE,
      ];

      // Since this generates absolute URLs, it can only be cached "per site".
+1 −11
Original line number Diff line number Diff line
@@ -2,8 +2,6 @@

namespace Drupal\Tests\node\Functional;

use Drupal\Component\Utility\Html;

/**
 * Tests the node/{node} page.
 *
@@ -37,16 +35,8 @@ public function testHtmlHeadLinks() {
   */
  public function testLinkHeader() {
    $node = $this->drupalCreateNode();

    $expected = [
      '<' . Html::escape($node->toUrl('canonical')->setAbsolute()->toString()) . '>; rel="canonical"',
      '<' . Html::escape($node->toUrl('canonical', ['alias' => TRUE])->setAbsolute()->toString()) . '>; rel="shortlink"',
    ];

    $this->drupalGet($node->toUrl());

    $links = $this->getSession()->getResponseHeaders()['Link'];
    $this->assertEquals($expected, $links);
    $this->assertArrayNotHasKey('Link', $this->getSession()->getResponseHeaders());
  }

  /**