diff --git a/core/lib/Drupal/Core/Url.php b/core/lib/Drupal/Core/Url.php index 2e78b09..69fd6bc 100644 --- a/core/lib/Drupal/Core/Url.php +++ b/core/lib/Drupal/Core/Url.php @@ -282,7 +282,7 @@ public static function createFromRequest(Request $request) { */ public static function fromEntityUri($uri) { if (strpos($uri, 'entity://') === 0) { - list($entity_path) = explode('entity://', $uri, 1); + list(, $entity_path) = explode('entity://', $uri, 2); list($entity_type, $id) = explode('/', $entity_path); return new Url("entity.{$entity_type}.canonical", [$entity_type => $id]); } diff --git a/core/tests/Drupal/Tests/Core/UrlTest.php b/core/tests/Drupal/Tests/Core/UrlTest.php index a93226a..8f16f75 100644 --- a/core/tests/Drupal/Tests/Core/UrlTest.php +++ b/core/tests/Drupal/Tests/Core/UrlTest.php @@ -444,6 +444,16 @@ public function accessProvider() { ); } + /** + * Tests the fromEntityUri() method. + */ + public function testFromEntityUri() { + $uri = 'entity://test_entity/1'; + $url = Url::fromEntityUri($uri); + $this->assertSame('entity.test_entity_type.canonical', $url->getRouteName()); + $this->assertEquals(['test_entity' => '1'] , $url->getRouteParameters()); + } + } class TestUrl extends Url {