har-extractor icon indicating copy to clipboard operation
har-extractor copied to clipboard

Fix HAR extraction for conflicting URL paths

Open acrefoot opened this issue 6 months ago • 1 comments

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.

acrefoot avatar Aug 14 '24 17:08 acrefoot