From 12c0582a5566b1414e68fadbff16ca2cb9ae024c Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Tue, 24 Dec 2019 14:24:24 +1100 Subject: [PATCH] Fixed alias using full uri instead of just path in iven subscriber. --- src/EventSubscriber/AliasSubscriber.php | 4 +++- tests/src/Functional/MinisiteTestBase.php | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/EventSubscriber/AliasSubscriber.php b/src/EventSubscriber/AliasSubscriber.php index 767235e..97ca5cb 100644 --- a/src/EventSubscriber/AliasSubscriber.php +++ b/src/EventSubscriber/AliasSubscriber.php @@ -2,6 +2,7 @@ namespace Drupal\minisite\EventSubscriber; +use Drupal\Component\Utility\UrlHelper; use Drupal\minisite\Asset; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\GetResponseEvent; @@ -35,7 +36,8 @@ public function onRequestSetController(GetResponseEvent $event) { // be as "lightweight" as possible as it will run before any other routes // are considered (it is still faster to run this before all RouterListener // processing). - $asset = Asset::loadByAlias($request->getRequestUri()); + $parsed_uri = UrlHelper::parse($request->getRequestUri()); + $asset = Asset::loadByAlias($parsed_uri['path']); if ($asset) { $request->attributes->set('_controller', '\Drupal\minisite\Controller\AliasController::deliverAsset'); $request->attributes->set('asset_id', $asset->id()); diff --git a/tests/src/Functional/MinisiteTestBase.php b/tests/src/Functional/MinisiteTestBase.php index 1df027e..12d4fe2 100644 --- a/tests/src/Functional/MinisiteTestBase.php +++ b/tests/src/Functional/MinisiteTestBase.php @@ -517,6 +517,15 @@ public function browseFixtureMinisiteAliased($alias, $description, $assets_paths $this->assertText('Page 2'); $this->assertUrl($alias . '/' . $assets_paths[2]); + + // Navigate to the page using URL with a query. + $this->drupalGet($alias . '/' . $assets_paths[1], [ + 'query' => [ + 'param' => 'val', + ], + 'fragment' => 'someid', + ]); + $this->assertResponse(200); } }