private function checkVisibility(\Drupal\node\NodeInterface $node) {

    $pages = '';
    if ($node->hasField('field_alert_visibility_pages')) {
      $pages = $node->get('field_alert_visibility_pages')->value;
    }

    $state = 'include';
    if ($node->hasField('field_alert_visibility_state')) {
      $state = $node->get('field_alert_visibility_state')->value;
    }

    $pages = Unicode::strtolower($pages);
    if (!$pages) {
      // Global alert.
      return TRUE;
    }


    // Convert path to lowercase. This allows comparison of the same path.
    // with different case. Ex: /Page, /page, /PAGE.
    // Compare the lowercase path alias (if any) and internal path.
    $current_path = $_GET['uri'];
    $path = $this->aliasManager->getAliasByPath($current_path);
    $path = Unicode::strtolower($path);

    // Do not trim a trailing slash if that is the complete path.
    $path = $path === '/' ? $path : rtrim($path, '/');

    $is_path_match = $this->pathMatcher->matchPath($path, $pages);
    if ($state == 'include' && $is_path_match || $state == 'exclude' && !$is_path_match) {
      // Local alert.
      return TRUE;
    }

    return FALSE;
  }