Skip to content

fix(path): honor empty parse and format fields#56

Open
ShiroKSH wants to merge 1 commit into
theMackabu:masterfrom
ShiroKSH:fix/path-empty-fields
Open

fix(path): honor empty parse and format fields#56
ShiroKSH wants to merge 1 commit into
theMackabu:masterfrom
ShiroKSH:fix/path-empty-fields

Conversation

@ShiroKSH

@ShiroKSH ShiroKSH commented Jul 14, 2026

Copy link
Copy Markdown

Summary

  • Return an empty dir from basename-only path.parse calls.
  • Let empty dir fall back to root and empty base fall back to name plus ext in path.format.
  • Add POSIX and Windows regressions.

Root cause

path.parse substituted a dot for a missing directory. path.format chose dir and base from their property type instead of their non-empty values.

Checks

  • node --check tests/test_path_parse_format.cjs
  • node tests/test_path_parse_format.cjs
  • git diff --check

Summary by CodeRabbit

  • Bug Fixes

    • Corrected path parsing so basename-only paths return an empty directory value.
    • Improved path formatting fallbacks when directory or basename components are empty or missing.
    • Ensured name and extension components are used appropriately when the basename is empty.
    • Preserved correct directory precedence for Windows-style paths.
  • Tests

    • Added coverage for POSIX and Windows path parsing and formatting edge cases.

@github-actions

Copy link
Copy Markdown
Contributor

Hi @ShiroKSH, thanks for your interest in contributing!

This project requires that pull request authors are vouched, and you are not in the list of vouched users.

This PR will be closed automatically. See https://github.com/theMackabu/ant/blob/master/CONTRIBUTING.md for more details.

@github-actions github-actions Bot closed this Jul 14, 2026
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 141abeff-1491-495b-8373-48a4b603c51c

📥 Commits

Reviewing files that changed from the base of the PR and between 78732d3 and 27184cc.

📒 Files selected for processing (2)
  • src/modules/path.c
  • tests/test_path_parse_format.cjs

📝 Walkthrough

Walkthrough

Path parsing now returns empty directories for basename-only paths. Path formatting distinguishes missing or empty dir and base values, applying root or name/ext fallbacks accordingly. New tests cover POSIX and Windows parse/format behavior.

Changes

Path component handling

Layer / File(s) Summary
Parse and format fallback behavior
src/modules/path.c, tests/test_path_parse_format.cjs
Parsing returns an empty dir for basename-only paths. Formatting tracks non-empty dir and base values to apply root or name/ext fallbacks, with tests covering POSIX and Windows cases.

Estimated code review effort: 2 (Simple) | ~10 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@theMackabu

Copy link
Copy Markdown
Owner

vouch @ShiroKSH

github-actions Bot added a commit that referenced this pull request Jul 14, 2026
@theMackabu theMackabu reopened this Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants