Remove bookmark prefix from naked URLs

See discussion here:
https://hubzilla.org/channel/adminsforum?mid=00a360a1-6281-52aa-b4de-65493b8899f5
This commit is contained in:
Harald Eilertsen
2026-04-22 13:22:32 +02:00
parent 782765e377
commit 7fc1d58b10
2 changed files with 8 additions and 7 deletions

View File

@@ -277,13 +277,10 @@ function red_zrl_callback($matches) {
$matches[2] = $t;
}
if($matches[1] === '#^')
$matches[1] = '';
if($zrl)
return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]' . $pts[0];
return $matches[1] . '[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]' . $pts[0];
return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]' . $pts[0];
return $matches[1] . '[url=' . $matches[2] . ']' . $matches[2] . '[/url]' . $pts[0];
}
/**

View File

@@ -19,9 +19,13 @@ class CleanupBBCodeTest extends UnitTestCase {
public static function cleanup_bbcode_provider(): array {
return [
'url followed by newline' => [
"#^[url=https://example.com]https://example.com[/url]\na test link",
"[url=https://example.com]https://example.com[/url]\na test link",
"https://example.com\na test link",
]
],
'bookmarked url' => [
"#^[url=https://example.com]https://example.com[/url] a test link",
"#^https://example.com a test link",
],
];
}
}