Skip to content

Fix filepath collisions 2 - #19

Open
milahu wants to merge 3 commits into
azu:masterfrom
milahu:fix-filepath-collisions-2
Open

Fix filepath collisions 2#19
milahu wants to merge 3 commits into
azu:masterfrom
milahu:fix-filepath-collisions-2

Conversation

@milahu

@milahu milahu commented Jun 10, 2026

Copy link
Copy Markdown

continue #13

acrefoot and others added 3 commits June 10, 2026 14:16
Problem:
The previous implementation couldn't handle cases where a HAR file
contained entries for both a URL and its subpath (e.g., 'foo' and 'foo/bar').
This led to conflicts when trying to represent both as filesystem paths.

Solution:
- Implement 'ensureDir' function to create nested directory structure
- Handle cases where a file exists where a directory is needed:
  - Move existing file to 'index' within a new directory
- Replace 'makeDir.sync' with this new, more flexible approach

This change allows us to correctly represent all HAR entries in the
filesystem, even when URL paths overlap. For example:
- 'server.com/foo' becomes 'server.com/foo/index'
- 'server.com/foo/bar' becomes 'server.com/foo/bar'

Testing:
Manually tested with HAR files containing conflicting URL paths.
Comment thread src/har-extractor.ts
}

if (fs.existsSync(outputPath)) {
const fileStat = fs.lstatSync(outputPath);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

TODO handle if (fileStat.isFile()) { ... } by adding suffixes

file
file.1
file.2
file.3

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