fix: Improve cleanPath os compatability#322
Open
thompson-tomo wants to merge 5 commits intothlorenz:masterfrom
Open
fix: Improve cleanPath os compatability#322thompson-tomo wants to merge 5 commits intothlorenz:masterfrom
thompson-tomo wants to merge 5 commits intothlorenz:masterfrom
Conversation
Contributor
Author
|
@AndrewSouthpaw This should be merged after #319 |
Contributor
There was a problem hiding this comment.
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
osmodule import to support cross-platform home directory resolution - Replaced
process.env.HOME + path.substr(1)withpath.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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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