Open jaydenseric opened 3 years ago
Also, the cleaning needs to scan for file:
URL paths with the CWD converted to the URL format, since a traditional file path and URL file path can differ in encoding of certain characters in the path string.
I'd help fix this.
stack-tools can parse and print URIs now!
Workaround is to set a non existing cwd:
const stackUtils = new StackUtils({ cwd: 'I want absolute paths' });
file://
URL paths can only be absolute:Yet the
clean
method strips out the CWD from thefile:
URLs, leaving thefile://
at the start, making them invalid.This is a pressing issue, because the error stack from errors thrown in an ESM file starts with the
file:
URL of the ESM. The ecosystem is currently migrating to vanilla ESM (in.mjs
files, or.js
files with package"type": "module"
) and more people will start to notice this bug.In
test.mjs
:Then, run
node test.mjs
and the console log is ([CWD]
substituting the absolute CWD path):Note the invalid
file://test.mjs:6:9
, it should betest.mjs:6:9
.