diff --git a/src/nex.php b/src/nex.php index ffbca52..2cb0419 100644 --- a/src/nex.php +++ b/src/nex.php @@ -220,30 +220,49 @@ $server->start( foreach ((array) scandir($goal) as $link) { - // Skip hidden entities and make sure the destination is accessible - if (!str_starts_with($link, '.') && is_readable($goal . $link)) + // Skip system entities + if (str_starts_with($link, '.')) { - // Directory - if (is_dir($link)) + // Keep parent navigation entities only + if ($link == '..' && $parent = realpath($goal . $link)) { - $links[] = sprintf( - '=> %s/', - urlencode( - $link - ) - ); + if (str_starts_with($parent . DIRECTORY_SEPARATOR, NEXT_PATH)) + { + if (is_readable($parent)) + { + $links[] = '=> ../'; + } + } } - // File - else + continue; + } + + // Directory + if (is_dir($goal . $link)) + { + if (is_readable($goal . $link)) { $links[] = sprintf( - '=> %s', + '=> %s/', urlencode( $link ) ); } + + continue; + } + + // File + if (is_readable($goal . $link)) + { + $links[] = sprintf( + '=> %s', + urlencode( + $link + ) + ); } }