Skip to content

Commit 05b83ae

Browse files
Fix: The folder name is properly displayed at root when calling prettyPrint(".") (instead of "./")
1 parent 17fe701 commit 05b83ae

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
- Line extension: empty string is permitted
1717
- Filtering: split into distinct directories and files filters
1818

19+
### Fixed
20+
- The folder name is properly displayed at root when calling `prettyPrint(".")` (instead of "./")
21+
1922
---
2023
## [0.0.4] - 2025-09-27
2124

src/main/java/io/github/computerdaddyguy/jfiletreeprettyprinter/DefaultFileTreePrettyPrinter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ public DefaultFileTreePrettyPrinter(PathToTreeScanner scanner, TreeEntryRenderer
1919

2020
@Override
2121
public String prettyPrint(Path path) {
22-
var tree = scanner.scan(path);
22+
Objects.requireNonNull(path, "path cannot be null");
23+
var cleanedPath = path.normalize().toAbsolutePath(); // required to avoid "./" at root when calling prettyPrint(".")
24+
var tree = scanner.scan(cleanedPath);
2325
return renderer.renderTree(tree);
2426
}
2527

0 commit comments

Comments
 (0)