Skip to content

Commit ecddc20

Browse files
author
Gabriel Schulhof
committed
prefix with file://
1 parent e2a7626 commit ecddc20

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/node_api.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,12 @@ void napi_module_register_by_symbol(v8::Local<v8::Object> exports,
577577
modobj->Get(context, node_env->filename_string()).ToLocal(&filename_js) &&
578578
filename_js->IsString()) {
579579
node::Utf8Value filename(node_env->isolate(), filename_js); // Cast
580-
module_filename = *filename;
580+
581+
// Turn the absolute path into a URL. Currently the absolute path is always
582+
// a file system path.
583+
// TODO(gabrielschulhof): Pass the `filename` through unchanged if/when we
584+
// receive it as a URL already.
585+
module_filename = std::string("file://") + (*filename);
581586
}
582587

583588
// Create a new napi_env for this specific module.

test/node-api/test_general/test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ const filename = require.resolve(`./build/${common.buildType}/test_general`);
55
const test_general = require(filename);
66
const assert = require('assert');
77

8-
assert.strictEqual(test_general.filename, filename);
8+
// TODO(gabrielschulhof): This test may need updating if/when the filename
9+
// becomes a full-fledged URL.
10+
assert.strictEqual(test_general.filename, `file://${filename}`);
911

1012
const [ major, minor, patch, release ] = test_general.testGetNodeVersion();
1113
assert.strictEqual(process.version.split('-')[0],

0 commit comments

Comments
 (0)