From e3eebcd95de6be2be78ea81edef00ab5c2355503 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 26 Feb 2025 15:32:36 +0000 Subject: calculate observer.baseurl from xchan_url since xchan_connurl is only set for zot xchans --- include/bbcode.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/include/bbcode.php b/include/bbcode.php index 15a75ce3f..65bda1b7b 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -1126,9 +1126,11 @@ function parseIdentityAwareHTML($Text) { if ($observer) { $s1 = ''; $s2 = ''; - $obsBaseURL = $observer['xchan_connurl']; - $obsBaseURL = preg_replace("/\/poco\/.*$/", '', $obsBaseURL); - $Text = str_replace('[observer.baseurl]', $obsBaseURL, $Text); + + $parsed = parse_url($observer['xchan_url']); + $observer_base_url = unparse_url($parsed, ['scheme', 'host', 'port']); + + $Text = str_replace('[observer.baseurl]', $observer_base_url, $Text); $Text = str_replace('[observer.url]',$observer['xchan_url'], $Text); $Text = str_replace('[observer.name]',$s1 . $observer['xchan_name'] . $s2, $Text); $Text = str_replace('[observer.address]',$s1 . $observer['xchan_addr'] . $s2, $Text); @@ -1311,9 +1313,11 @@ function bbcode($text, $options = []) { if ($observer) { $s1 = ''; $s2 = ''; - $obsBaseURL = $observer['xchan_connurl']; - $obsBaseURL = preg_replace("/\/poco\/.*$/", '', $obsBaseURL); - $text = str_replace('[observer.baseurl]', $obsBaseURL, $text); + + $parsed = parse_url($observer['xchan_url']); + $observer_base_url = unparse_url($parsed, ['scheme', 'host', 'port']); + + $text = str_replace('[observer.baseurl]', $observer_base_url, $text); $text = str_replace('[observer.url]',$observer['xchan_url'], $text); $text = str_replace('[observer.name]',$s1 . $observer['xchan_name'] . $s2, $text); $text = str_replace('[observer.address]',$s1 . $observer['xchan_addr'] . $s2, $text); -- cgit v1.2.3