diff --git a/src/Form/FlagConfirmBaseForm.php b/src/Form/FlagConfirmBaseForm.php
index 9e9b06f..4102a9a 100644
--- a/src/Form/FlagConfirmBaseForm.php
+++ b/src/Form/FlagConfirmBaseForm.php
@@ -8,6 +8,7 @@ namespace Drupal\flag\Form;
 
 use Drupal\Core\Form\ConfirmFormBase;
 use Drupal\Core\Url;
+use Drupal\Component\Utility\UrlHelper;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\flag\FlagInterface;
 
@@ -48,9 +49,10 @@ abstract class FlagConfirmBaseForm extends ConfirmFormBase {
    * {@inheritdoc}
    */
   public function getCancelUrl() {
-    $destination = \Drupal::request()->get('destination');
-    if (!empty($destination)) {
-      return Url::createFromPath($destination);
+    $query = $this->getRequest()->query;
+    if ($query->has('destination')) {
+      $options = UrlHelper::parse($query->get('destination'));
+      return Url::fromUri('internal:/' . $options['path'], $options);
     }
 
     return $this->entity->urlInfo();
