protected function AlinkPostRenderer::normalizeUri in Alinks 8
Normalize the URLs with front links and internal links.
Parameters
string $uri: A url to be normalized.
Return value
string The normalized URL.
1 call to AlinkPostRenderer::normalizeUri()
- AlinkPostRenderer::extractExistingLinks in src/
AlinkPostRenderer.php - Extract all of the links in an xpath query.
File
- src/
AlinkPostRenderer.php, line 232
Class
- AlinkPostRenderer
- Class AlinkPostRenderer.
Namespace
Drupal\alinksCode
protected function normalizeUri($uri) {
// If we already have a scheme, we're fine.
if (empty($uri) || !is_null(parse_url($uri, PHP_URL_SCHEME))) {
return $uri;
}
// Remove the <front> component of the URL.
if (strpos($uri, '<front>') === 0) {
$uri = substr($uri, strlen('<front>'));
}
// Add the internal: scheme and ensure a leading slash.
return 'internal:/' . ltrim($uri, '/');
}