Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
lib: move ToNamespacedPath call to c++
  • Loading branch information
anonrig committed Jun 30, 2024
commit eafad4dbbaeec1e28bb2df78b34640491cb259bc
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