Skip to content

fix: Improve cleanPath os compatability#322

Open
thompson-tomo wants to merge 5 commits intothlorenz:masterfrom
thompson-tomo:patch-3
Open

fix: Improve cleanPath os compatability#322
thompson-tomo wants to merge 5 commits intothlorenz:masterfrom
thompson-tomo:patch-3

Conversation

@thompson-tomo
Copy link
Contributor

@thompson-tomo thompson-tomo commented Mar 4, 2026

This resolves the merge conflicts in #249 and will allow that to be closed. Feedback from that pr has been implemented hence #319 which is to be merged first and enable this to be ready.

Uses os.homedir() since that works better on non-POSIXy platforms.

I know this code uses old conventions and methods, so if NodeJS version compatability is a concern (even though they have been unsupported for decades), these are when these functions were added to NodeJS:

Closes: #249

@thompson-tomo thompson-tomo marked this pull request as ready for review March 4, 2026 13:32
@thompson-tomo
Copy link
Contributor Author

@AndrewSouthpaw This should be merged after #319

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the cross-platform compatibility of the cleanPath function in doctoc.js. Previously, tilde (~) expansion used process.env.HOME, which doesn't work on Windows. The fix uses os.homedir() and path.join() for proper platform-agnostic path handling. This also relies on a prior PR (#319) that renamed the path parameter to filepath to avoid shadowing the path module.

Changes:

  • Added os module import to support cross-platform home directory resolution
  • Replaced process.env.HOME + path.substr(1) with path.join(os.homedir(), filepath.substr(1)) for proper OS-agnostic tilde expansion

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

3 participants