har-extractor
har-extractor copied to clipboard
Fix HAR extraction for conflicting URL paths
This PR addresses an issue where HAR entries with conflicting prefixes could not be properly represented in the filesystem. The changes implement a more robust directory creation process that can handle cases where a file and a directory might need to exist at the same path.
Changes
- Implemented ensureDir function to manage directory creation
- Replaced makeDir.sync with custom ensureDir logic
- Added handling for cases where file and directory names conflict
- Improved error handling for directory creation process
- Removed unused makeDir import
Implementation Details
The new ensureDir function walks through each part of a path, creating directories as needed. If it encounters a file where a directory should be, it moves the file to an index
file within a new directory at that location. This allows us to represent both server.com/foo (as server.com/foo/index) and server.com/foo/bar (as server.com/foo/bar) in the filesystem.