diff --git a/src/Service/UWService.php b/src/Service/UWService.php index 0f8e6abe35aa7636a9f53c7d675e1efa0df434c9..0391b4510760e64ed1ab236ced22751ddd92fd92 100644 --- a/src/Service/UWService.php +++ b/src/Service/UWService.php @@ -2,6 +2,7 @@ namespace Drupal\uw_cfg_common\Service; +use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Database\Connection; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; @@ -492,7 +493,15 @@ class UWService implements UWServiceInterface { // If there is data in the link, get the variables. if ($link_data) { - $return_link_data['uri'] = $link_data[0]['uri']; + + // Get correct uri, if external just use uri from node + // value, if not, then generate url from uri. + if (UrlHelper::isExternal($link_data[0]['uri'])) { + $return_link_data['uri'] = $link_data[0]['uri']; + } + else { + $return_link_data['uri'] = URL::fromUri($link_data[0]['uri'])->toString(); + } $return_link_data['title'] = $link_data[0]['title']; }