Skip to content

Commit

Permalink
Fixed alias using full uri instead of just path in iven subscriber.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Skrypnyk committed Dec 24, 2019
1 parent d222dc6 commit 12c0582
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/EventSubscriber/AliasSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
9 changes: 9 additions & 0 deletions tests/src/Functional/MinisiteTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}

0 comments on commit 12c0582

Please sign in to comment.