diff --git a/src/Plugin/collect/Schema/FetchUrlSchema.php b/src/Plugin/collect/Schema/FetchUrlSchema.php
index 525eb91..cd60025 100644
--- a/src/Plugin/collect/Schema/FetchUrlSchema.php
+++ b/src/Plugin/collect/Schema/FetchUrlSchema.php
@@ -96,8 +96,7 @@ class FetchUrlSchema extends SchemaBase implements SpecializedDisplaySchemaInter
     }
 
     // The response body.
-    $current_url = explode('/', \Drupal::requestStack()->getCurrentRequest()->getRequestUri());
-    $collect_container_id = end($current_url);
+    $collect_container_id = \Drupal::requestStack()->getCurrentRequest()->get('collect_container')->id();
     $url = \Drupal::url('collect.generate_page', ['collect_container' => $collect_container_id], ['absolute' => TRUE]);
     $output['body'] = array(
       '#type' => 'link',
diff --git a/src/Tests/CollectWebTest.php b/src/Tests/CollectWebTest.php
index bc21bb5..4f6f259 100644
--- a/src/Tests/CollectWebTest.php
+++ b/src/Tests/CollectWebTest.php
@@ -123,6 +123,19 @@ class CollectWebTest extends WebTestBase {
     $this->assertNoLink($web_page_container->getOriginUri());
     $this->clickLink(t('2'));
     $this->assertResponse(200);
+
+    // Apply Fetch URL schema plugin.
+    // Assert a generated web page is accessible.
+    $this->clickLink(t('Set up a Collect Fetch URL schema'));
+    $this->drupalPostForm(NULL, [
+      'id' => 'collect_fetch_url',
+    ], t('Save'));
+    $this->clickLink(t('Show content in a new window'));
+    $this->assertResponse(200);
+    $this->drupalGet('admin/content/collect');
+    $this->clickLink(t('View'));
+    $this->clickLink(t('Show content in a new window'));
+    $this->assertResponse(200);
   }
 
   /**
