fix: stay on same domain when clicking links

main
gravel 4 months ago
parent 6e0f7a4f39
commit 96fbe5e434
No known key found for this signature in database
GPG Key ID: CA95FFF4E0123903

@ -274,7 +274,7 @@ class MarkdownEntity {
private array $props;
public function renderStart(): string {
global $REPOSITORY_CANONICAL_URL_FILES;
global $REPOSITORY_CANONICAL_URL_FILES, $SITE_CANONICAL_URL;
$type = $this->type;
switch ($type) {
@ -283,6 +283,10 @@ class MarkdownEntity {
if (!str_starts_with($href, "#") && !str_contains($href, "://")) {
$href = "$REPOSITORY_CANONICAL_URL_FILES/$href";
}
remove_prefix($href, $SITE_CANONICAL_URL);
if (empty($href)) {
$href = "/";
}
return "\n<a href=\"{$href}\">";
default: return "\n<$type>";
}

Loading…
Cancel
Save