Fix auto-link URLs: prevent double language prefix from relative link conversion

This commit is contained in:
2026-07-21 13:00:24 +02:00
parent 52e1ce0b20
commit a048056b6b
+2 -2
View File
@@ -579,9 +579,9 @@ class CodePressCMS {
// Auto-link page titles to existing content pages (but not in H1 tags) // Auto-link page titles to existing content pages (but not in H1 tags)
$body = $this->autoLinkPageTitles($body, $cleanName); $body = $this->autoLinkPageTitles($body, $cleanName);
// Convert relative internal links to clean URLs // Convert relative internal links to clean URLs (skip already-prefixed URLs)
$body = preg_replace('/href="\/blog\/([^"]+)"/', 'href="/' . $this->currentLanguage . '/blog/$1"', $body); $body = preg_replace('/href="\/blog\/([^"]+)"/', 'href="/' . $this->currentLanguage . '/blog/$1"', $body);
$body = preg_replace('/href="\/([^"]+)"/', 'href="/' . $this->currentLanguage . '/$1"', $body); $body = preg_replace('/href="\/(?!nl\/|en\/|nl"|en")([^"]+)"/', 'href="/' . $this->currentLanguage . '/$1"', $body);
return [ return [
'title' => $title ?: $cleanName ?: 'Untitled', 'title' => $title ?: $cleanName ?: 'Untitled',