Skip to content

fix: clean file:// URL prefixes when stripping cwd in clean() and parseLine() - #79

Open
chiragbitoni wants to merge 1 commit into
tapjs:mainfrom
chiragbitoni:fix/file-urls-in-clean-and-parseline
Open

chiragbitoni wants to merge 1 commit into
tapjs:mainfrom
chiragbitoni:fix/file-urls-in-clean-and-parseline

Conversation

@chiragbitoni

Copy link
Copy Markdown

Description

When error stack traces originate from ESM modules, Node formats file paths as file:// URLs (e.g. at file:///user/dev/project/test.mjs:6:9).
Previously, clean() stripped ${this._cwd}/, leaving invalid paths like file://test.mjs:6:9 instead of test.mjs:6:9.
Similarly, parseLine()'s setFile() helper only checked filename.startsWith(${cwd}/), failing to strip cwd from file://-prefixed filenames.

This PR:

  1. Strips file:/// and file:// prefixes when matching and stripping the configured cwd in clean().
  2. Updates setFile() to recognize file:/// and file:// prefixes matching cwd.
  3. Adds unit tests for both clean() and parseLine() on Linux and Windows file:// formats with 100% test coverage.

Fixes #60

Checklist

  • 100% tests pass with full code coverage
  • regression tests included
  • commit signed off with DCO

…seLine()

When error stacks originate in ESM modules, paths are formatted as file:// URLs. Previously, clean() only stripped \/ leaving file:// at the start of relative paths. Similarly, parseLine() failed to strip cwd from file:// URLs in setFile(). Handle file:// and file:/// URL prefixes matching cwd when normalizing paths.

Fixes tapjs#60

Signed-off-by: Chirag Bitoni <chiragbitoni4994@gmail.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.

Incorrectly cleans file:// paths

1 participant