Browse Source

Applied changes from the patch provided in #5

merge-requests/34/head
prashantdsala 1 year ago committed by Ivan
parent
commit
91992ea10d
  1. 4
      src/TwigTweakExtension.php

4
src/TwigTweakExtension.php

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

Loading…
Cancel
Save