I have used the following code in a Drupal 8 theme file.
$current_path = \Drupal::request()->getRequestUri();
$path_alias = Unicode::strtolower(\Drupal::service('path.alias_manager')->getAliasByPath($current_path));
$visiblity = \Drupal::service('path.matcher')->matchPath($path_alias, $pages);
$pages
contains values like '<front>'
or '/blog'
.
$visiblity
is set to FALSE
for /, but to TRUE
for /node; Both are the front page.
What is the wrong with my code?