Skip to content

Commit

Permalink
Merge pull request #1877 from tomudding/fix/lang-href-without-slash
Browse files Browse the repository at this point in the history
fix: alternate href lang missing / when language is not in the path
  • Loading branch information
tomudding authored Jul 28, 2024
2 parents 347e325 + cd6c391 commit e1c9ca0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions module/Application/view/layout/layout.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ use Laminas\View\Renderer\PhpRenderer;
$strippedPath = '';
}

if (
'' !== $strippedPath
&& !str_starts_with($strippedPath, '/')
) {
// If not at the "root", add the slash back if it is not present.
$strippedPath = '/' . $strippedPath;
}

$this->hrefLang()->setHrefLang(Languages::EN, $this->serverUrl($this->basePath('en' . $strippedPath)))
->setHrefLang(Languages::NL, $this->serverUrl($this->basePath('nl' . $strippedPath)));
}
Expand Down

0 comments on commit e1c9ca0

Please sign in to comment.