Skip to content

Commit 47a822d

Browse files
Update index.php
1 parent 280b98e commit 47a822d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tunnel/index.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ function join_path(...$paths) {
6969

7070
function format_slug($slug)
7171
{
72-
$slug = trim($slug, DS);
73-
$slug = trim($slug, "/");
7472
$slug = str_replace(DS, "/",$slug);
73+
$slug = trim($slug, "/")."/";
7574
return $slug;
7675
}
7776

@@ -153,6 +152,7 @@ function parse($file) {
153152
$content = preg_replace('/^(?:\s*#\w+\s*?)*$/m', '', $content);
154153
// Use regular expression to find and modify Markdown links
155154
$pattern = '/\[(.*?)\]\((.*?)\)/';
155+
$content = preg_replace_callback('/\[(.*?)\]\((.*?)\)/', fn($matches) => '[' . $matches[1] . '](' . rtrim($matches[2], '/') . '/)', $content);
156156
$content = preg_replace_callback($pattern, 'add_base_to_links', $content);
157157
$content = $parsedown->text($content);
158158
$page['content']= trim($content, " \n\r\t");
@@ -173,8 +173,10 @@ function parse($file) {
173173
{
174174
$slug = str_replace(".".$ext, "", $slug);
175175
}
176+
176177
$page['slug'] = format_slug($slug);
177-
178+
/*Adding a trailing slash to be consistent in URL scheme */
179+
178180

179181
$page['file_path'] = $file;
180182

0 commit comments

Comments
 (0)