diff --git a/src/TwigTweakExtension.php b/src/TwigTweakExtension.php index d007798..9473462 100644 --- a/src/TwigTweakExtension.php +++ b/src/TwigTweakExtension.php @@ -4,6 +4,7 @@ namespace Drupal\twig_tweak; use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\Unicode; +use Drupal\Component\Utility\UrlHelper; use Drupal\Component\Uuid\Uuid; use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Entity\EntityInterface; @@ -353,6 +354,9 @@ class TwigTweakExtension extends AbstractExtension { $options['language'] = $language; } } + if (UrlHelper::isExternal($user_input)) { + return Url::fromUri($user_input, $options); + } if (!in_array($user_input[0], ['/', '#', '?'])) { $user_input = '/' . $user_input; }