~magentix/Leo

7bc4096bfd74a09661d242edf8bb7f8cff73a838 — Matthieu Vion 2 years ago fb9c844
Load index for a request with or without a trailing slash
1 files changed, 5 insertions(+), 5 deletions(-)

M leo.php
M leo.php => leo.php +5 -5
@@ 44,13 44,13 @@ function getContent(array $url): string
        return "59 bad request\r\n";
    }

    $path = $url['path'] ?? '/';
    if (str_ends_with($path, '/')) {
        $path .= 'index.gmi';
    $path = $url['path'] ?? '/index.gmi';
    if (!str_ends_with($path, '.gmi')) {
        $path = rtrim($path, '/') . '/index.gmi';
    }
    
    $file = ROOT . 'capsule' . str_replace('../', '', $path);

    if (!str_ends_with($file, 'gmi') || !file_exists($file)) {
    if (!file_exists($file)) {
        return "51 Not found\r\n";
    }