Skip to content

Conversation

@miguelramos
Copy link
Member

Implement the PathExt trait for synchronous path normalization without I/O:

  • Add PathExt trait extending std::path::Path with normalize() method
  • Implement for both Path and PathBuf types
  • Resolve . (current dir) and .. (parent dir) components logically
  • Handle edge cases: empty paths, multiple parent dirs, root paths
  • Preserve parent dirs for relative paths going above start
  • Support Windows drive prefixes (C:) with platform-specific tests
  • Handle Unicode paths and special characters
  • Comprehensive documentation with examples for all scenarios
  • 46 unit tests covering absolute, relative, edge cases, and complex scenarios
  • Public re-export of PathExt trait from crate root

Algorithm correctly handles:

  • /a/b/../c -> /a/c (absolute with parent)
  • ./a/./b -> a/b (relative with current dir)
  • a/b/../../c -> c (resolution to single component)
  • ../../file -> ../../file (preserved parent dirs)
  • Empty path -> . (current directory)

Closes: workspace-node-tools-60y.1

Implement the PathExt trait for synchronous path normalization without I/O:

- Add PathExt trait extending std::path::Path with normalize() method
- Implement for both Path and PathBuf types
- Resolve . (current dir) and .. (parent dir) components logically
- Handle edge cases: empty paths, multiple parent dirs, root paths
- Preserve parent dirs for relative paths going above start
- Support Windows drive prefixes (C:) with platform-specific tests
- Handle Unicode paths and special characters
- Comprehensive documentation with examples for all scenarios
- 46 unit tests covering absolute, relative, edge cases, and complex scenarios
- Public re-export of PathExt trait from crate root

Algorithm correctly handles:
- /a/b/../c -> /a/c (absolute with parent)
- ./a/./b -> a/b (relative with current dir)
- a/b/../../c -> c (resolution to single component)
- ../../file -> ../../file (preserved parent dirs)
- Empty path -> . (current directory)

Closes: workspace-node-tools-60y.1
@miguelramos miguelramos self-assigned this Jan 13, 2026
@miguelramos miguelramos added ♨️ ACTION: pull request Pull request ❤️‍🔥 TYPE: Feature New feature or request 🧨 BREAKING CHANGE No previous compatibility labels Jan 13, 2026
On Windows, paths starting with / are 'rooted' but not absolute.
Absolute paths on Windows require a drive prefix (e.g., C:\).
Split test into Unix and Windows variants with appropriate paths.
@miguelramos miguelramos merged commit 5d0e445 into feat/next-evolution Jan 13, 2026
5 checks passed
@miguelramos miguelramos deleted the feature/workspace-fs-pathext-module branch January 13, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

♨️ ACTION: pull request Pull request 🧨 BREAKING CHANGE No previous compatibility ❤️‍🔥 TYPE: Feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants