Skip to content

Commit

Permalink
lib: move ToNamespacedPath call to c++
Browse files Browse the repository at this point in the history
PR-URL: nodejs#53654
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
  • Loading branch information
anonrig authored Jul 4, 2024
1 parent 20fbfaf commit 14e9119
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 1 addition & 4 deletions lib/internal/modules/esm/formats.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const {

const { getOptionValue } = require('internal/options');
const { getValidatedPath } = require('internal/fs/utils');
const pathModule = require('path');
const fsBindings = internalBinding('fs');
const { fs: fsConstants } = internalBinding('constants');

Expand Down Expand Up @@ -48,9 +47,7 @@ function mimeToFormat(mime) {
*/
function getFormatOfExtensionlessFile(url) {
if (!experimentalWasmModules) { return 'module'; }

const path = pathModule.toNamespacedPath(getValidatedPath(url));

const path = getValidatedPath(url);
switch (fsBindings.getFormatOfExtensionlessFile(path)) {
case fsConstants.EXTENSIONLESS_FORMAT_WASM:
return 'wasm';
Expand Down
4 changes: 2 additions & 2 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2966,8 +2966,8 @@ static void GetFormatOfExtensionlessFile(
CHECK(args[0]->IsString());

Environment* env = Environment::GetCurrent(args);
node::Utf8Value input(args.GetIsolate(), args[0]);

BufferValue input(args.GetIsolate(), args[0]);
ToNamespacedPath(env, &input);
THROW_IF_INSUFFICIENT_PERMISSIONS(
env, permission::PermissionScope::kFileSystemRead, input.ToStringView());

Expand Down

0 comments on commit 14e9119

Please sign in to comment.