I'm using Bootstrap with the link_attributes module. When adding a class to an external link, a fatal error occurs:

The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">UnexpectedValueException</em>: External URLs do not have an internal route name. in <em class="placeholder">Drupal\Core\Url-&gt;getRouteName()</em> (line <em class="placeholder">583</em> of <em class="placeholder">core/lib/Drupal/Core/Url.php</em>). <pre class="backtrace">Drupal\bootstrap\Plugin\Preprocess\Menu-&gt;convertAttributes(Array) (Line: 23)
Drupal\bootstrap\Plugin\Preprocess\Menu-&gt;preprocessVariables(Object) (Line: 53)
Drupal\bootstrap\Plugin\Preprocess\PreprocessBase-&gt;preprocess(Array, &#039;menu&#039;, Array) (Line: 1408)

Adding a check to ensure that the link is routed prior to grabbing the route is a must here.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

brooke_heaton created an issue. See original summary.

brooke_heaton’s picture

Assigned: Unassigned » brooke_heaton
brooke_heaton’s picture

Patch adds an isRouted check on the url before grabbing a route name.

markhalliwell’s picture

Assigned: brooke_heaton » Unassigned
Status: Active » Fixed

Ah, great catch. Ty!

brooke_heaton’s picture

Wow that was fast. Thanks Mark!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.